Solved

Generate PostData value for WebBrowser

Posted on 2003-11-12
4
1,676 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month11 days, 4 hours left to enroll

632 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