Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Generate PostData value for WebBrowser

Posted on 2003-11-12
4
Medium Priority
?
1,677 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 1000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

722 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