Hi Cosmin,
What you have suggested is basically what I have tried -- but it does
not seem to work for www,morningstar.com. I have used an HTTP sniffer
(by Effetech) to capture the traffic involved in a login process (over
100 transfers including graphics and ads!), and then tried sending the
pertinent "Get" requests in a new session. I have tried this from
Delphi, and by pasting the strings into FireFox's Address bar. I simply
cannot get it to work; there seem to be some cookie interactions that
I'm not accounting for, even though I'm repeating everything sent
(knowingly) from my end in a successful "manual" login.
So ... what I need ... is a browser Delphi component that uses TIdHTTP
(and hence TIdCookieManager), so I can let the user carry out the login,
and then conduct the rest of my information retrieval programatically.
Any suggestions, anybody?
Rainer
Cosmin Prund wrote:
>
> I think you sent this message to my private address in error.
>
> I forwarded the message to the list so everyone can see it.
>
>
>
> I'm suggesting automating the login using TiDHTTP. Unless the login
> screen requires JavaScript (sometimes even if it does require
> JavaScript), you can automate the process. Here's an example of what
> I'm thinking of:
>
>
>
> procedure LogIn;
>
> var L:TStringList;
>
> begin
>
> HTTP.Get('login-screen.php');
>
> L := TStringList.Create;
>
> Try
>
> L.Add('username=myusername');
>
> L.Add('password=mypassword');
>
> HTTP.Post('login-screen-processor.php', L);
>
> Finally L.Free;
>
> End;
>
> end;
>
>
>
> You essentially start at the login-screen. This is the URL you'd type
> in a browser to get to the site. Next you'd setup a "response" and
> post it back to the server. Depending on how security is implemented,
> you'll need to parse the result you got for the "Get" statement and
> add to your "response" strings all of the fields in the login form.
> You might also need to parse the result to find the actual "action"
> for the login form. None of this should be that difficult...
>
>
>
> Can you post the URL to the site you want to automatically log on to
> so we can take a look at it, and maybe suggest a different route?
>
>
>
> --
>
> Cosmin Prund
>
>
>
> *From:* Rainer von Saleski [mailto:[EMAIL PROTECTED]
> *Sent:* Thursday, July 05, 2007 11:23 PM
> *To:* Cosmin Prund
> *Subject:* Re: Delphi Digest, Vol 54, Issue 3
>
>
>
> Thanks for the reply, Cosmin!
>
> Unfortunately, the TWebBrowser component seems to have nothing to do
> with TIdHTTP ... so using TWebBrowser to do the login does not create
> cookies where TIdHTTP can find them, and I cannot login that way.
>
> Simply sending the login URL with TIdHTTP does not work either ...
> apparently there is some preparation that goes on before getting to
> the login screen that is needed.
>
> Does Indy have an equivalent (in part or in whole) of the
> functionality of TWebBrowser that uses TIdHTTP rather than the Windows
> DLL? I don't seem to be able to find it.
>
> Thanks in advance,
> Rainer
>
>
>
>
> ------------------------------------------------------------------------
>
>
>
> Subject:
>
> RE: Cookies
>
> From:
>
> "Cosmin Prund" <[EMAIL PROTECTED]>
> <mailto:[EMAIL PROTECTED]>
>
> Date:
>
> Tue, 3 Jul 2007 10:21:04 +0300
>
> To:
>
> "Borland's Delphi Discussion List" <[email protected]>
> <mailto:[email protected]>
>
>
>
> To:
>
> "Borland's Delphi Discussion List" <[email protected]>
> <mailto:[email protected]>
>
>
>
> From: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> [mailto:[EMAIL PROTECTED]
> On
> Behalf Of Rainer von Saleski
> Sent: Monday, July 02, 2007 6:12 PM
> To: [email protected] <mailto:[email protected]>
> Subject: Cookies
>
> I'm doing just fine using HTTP.Get (Delphi 7) to fetch the web data I
> need ... except that I cannot figure out how to set up the cookies
>
> that
>
>
> the site I'm contacting needs to log me in.
>
>
>
> Indy stores its cookies in its own place ... but where is that? If I
>
> knew, I could just copy in Firefox's cookies for that site.
>
>
>
> If I use TWebBrowser to let the user carry out a login, the cookies do
>
> not end up in Indy's world ... and I'm not logged in for HTTP.Get.
>
>
>
> The site's login page is sufficiently complicated, I cannot figure out
>
> what URL to send to simply do the login. Is there a way to "sniff"
>
>
>
> the
>
>
> traffic between a browser (any browser) and the internet?
>
>
>
> Answers to any of these avenues will probably solve my problem!
>
>
>
> Thanks,
>
> Rainer
>
>
>
>
> Hello there!
>
> Indy has its own cookie manager and you should use that:
> TIdCookieManager (it's on the Indy Misc page); Once you hook it up to
> the HTTP component you've got nothing else to do, it just works. As for
> copying the cookie from Firefox... it might work, it might not work. It
> depends on how the cookie is constructed and how it is validated.
>
> It just might be easier to do the login from Delphi + Indy (this might
> also be more portable) - but you'd need a bit of HTML knowledge to do
> this! Not much knowledge (I did it once and I can't say I know HTML or
> JavaScript).
>
> --
> Cosmin Prund
>
>
>
> ------------------------------------------------------------------------
>
>
>
>
> _______________________________________________
> Delphi mailing list -> [email protected] <mailto:[email protected]>
> http://www.elists.org/mailman/listinfo/delphi
>
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi