Post values in HTMLforms without using TwebBrowser
Possible Duplicate:
Without TWebBrowser input values in form on Button Click and get next webpage response
We are working with Delphi Xe2 and Indy 10 components.
We need to input the values in HTML page and click search button and get next result web page without using TWebBrowser. When We post the parameters on the URL, I am unable to get the result webpage.
On Post, we get the current page HTML code. How could we get the result web page in response?
Code we are using:
procedure TForm1.Button1Click(Sender: TObject); Var aStream : TStringStream; data : TIdMultiPartFormDataStream; begin aStream := TStringStream.Create; data := TIdMultiPartFormDataStream.Create; try with IdHTTP1 do begin data.AddFormField('DEP_PORT', 'Basel'); data.AddFormField('ARR_PORT', 'Gaziantep'); Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0'; Request.AcceptLanguage := 'en-US,en;q=0.5'; Request.Connection := 'keep-alive'; Request.Accept := 'text/html'; IOHandler := SSL; try Post('https://sun.sunexpress.com.tr/web/RezvEntry.xhtml?LANGUAGE=EN', data, aStream); except on E: Exception do showmessage('Error encountered during POST: ' + E.Message); end; end; Memo1.Lines.Add(aStream.DataString); except end; end;
The web site you are referring to also adds a jsessionid to the post-url. Maybe you cannot post without a valid jsessionid?
链接地址: http://www.djcxy.com/p/60478.html上一篇: Firemonkey TEdit大写