Solved

Generate PostData value for WebBrowser

Posted on 2003-11-12
4
1,672 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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
control image tags in a string ? 12 170
Dev express lookupcombo 3 64
Installshield for Embarcadero EX 10.1 Berlin 4 92
Problem working with dynamic array - help 2 48
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 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