Solved

Generate PostData value for WebBrowser

Posted on 2003-11-12
4
1,660 Views
Last Modified: 2012-05-04
Hi,

I want download page from a site that required login before entering.
I have username and password for the site, but want enter it programatically (without manually entering username/password on site logon page).

I tried use webbrowser for the task.
I found that I can use OnBeforeNavigate2 event.
There is parameter PostData that provides required information for the server.

Question is : how to generate a value of PostData parameter?

Regards.
0
Comment
Question by:Slavak
  • 3
4 Comments
 
LVL 26

Accepted Solution

by:
EddieShipman earned 250 total points
ID: 9737060
Here's how to do it with the Indy idHTTP component.

procedure TForm1.SendPostData;
Var
  aStream: TMemoryStream;
  Params: TStringStream;
begin
  aStream := TMemoryStream.create;
  Params := TStringStream.create('');

  try
    with IdHTTP1 do
    begin
      Params.WriteString(URLEncode('teste=' + 'yes' + '&'));
      Params.WriteString(URLEncode('name=' + 'ivan' + '&'));
      Params.WriteString(URLEncode('number=' + '102'));
      Request.ContentType := 'application/x-www-form-urlencoded';
      try
        Post('http://localhost/teste.asp', Params, aStream);
      except
        on E: Exception do
          showmessage('Error encountered during POST: ' + E.Message);
      end;
    end;
  aStream.WriteBuffer(#0' ', 1);
  aStream.Position := 0;
  Memo1.Lines.LoadFromStream(aStream);
  except
  end;
end;

Here is how using TWebBrowser:
http://www.members.shaw.ca/iedelphi/webbrowser.htm#advanced9
0
 
LVL 3

Author Comment

by:Slavak
ID: 9737712
Thanks, Eddie.

Points yours, but can you answer me for some related questions?

-- does Indy components provides support for https protocol?
-- does Indy can download web pages faster then webbrowser?
-- do you know any other free Delphi component that can download http/https pages faster?

Slava.

P.S. I will be glad to get answer for this questions from anyone. I will give aditional points for the answer.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 9738941
Yes
Yes
don't know
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 9738946
If you are not needing to interact with the page, I'd suggest using idHTTP because you only
get back the HTML, not the images, objects, etc...
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now