VB: How do i POST to HTTPS with custom headers (referer, cookie)
Here's exactely what im trying to accomplish.... with the MS WebBrowser Control i believe ican do it.
I want an application that would mimic what Intenet Explorer does when John Doe logs on to www.aol.com (post via https with cookie and referer) in order to read his mail.
Then i want to load all my AOL mail (subject,from,date) thats on the page into a list in my VB application. So i need to :
(A)
1. be able to communicate with an HTTPS server (POST and GET with custom cookie and referer headers)
2. read the HTTPS server response, including all headers (so i can retrieve and resend the cookie)
3. use WebBrowser.Navigate method of the WebBrowser control to do the POST that logs me on
4. parse the resulting html response and extract the subject/date/from of the mails
or better yet ..
(B)
1. be able to programatically assign values (username and password) to the <INPUT> tags on the form on the document contained by my WebBrowser control
2. programatically click the submit button to log on
3. parse the resulting html response and extract the subject/date/from of the mails
I tried to find out how to reference to the actual DOCUMENT object so i can do something like described below.
Lets say that the server returns an HTML document that contains a <FORM name="the_form" action="HTTPS://www.isp.com/login.pl" method="POST">
In DHTML i would refer to the FORM something like document.forms[1] or document.forms["the_form"]
Is there a way to programatically interact with this form on this page displayed in my WebBrowser control in my application? ... say in DHTML i can programatically submit the form with something like document.form[1].submit ....but how do i do that in my VB app (other than scenario (A) above ...where i have to do the parsing through the actual body of the html, extracting the form, all the inputs, the method, the action and then using WebBrowser.Navigate method of the WebBrowser control (and forget about any script processing that a <script> might do on this form - which is basically a no-no...)
Again, basically i want to mimic an actual user
1. going to aol.com (wait for page load)
2. entering the name and password
3. clicking the submit button (wait for responce page to load)
4. clicking on read mail (wait for page load)
then i can parse the code and load into a listbox in my application - all mail displayed in this page
I tried to be as descriptive as a i can thus the long post here... I KNOW I can do this using the WebBrowser control...just dont know how
Thanks a lot if u can help. (maybe someone can post a link to a site explaining how to programatically interact with the HTML Elements in a document displayed in a WebBrowser control...that would be great)
28-02-2003 at 03:25 AM
|
win_dir Level: VB Guru Registered: 04-08-2002 Posts: 390
Re: VB: How do i POST to HTTPS with custom headers (referer, cookie)
Have you looked around or even asked AOL to see if they have a POP3 server you can access to collect the emails or even some sort of SDK? It seems like your doing an awful lot of work for not much result. What is your purpose for making this application anyway?
Re: VB: How do i POST to HTTPS with custom headers (referer, cookie)
to automate the downloading of large files that come attached to email... if u use the AOL downloader the speed is 3 times slower than through their web interface
and...no they dont have a publickly available pop3...or sdk for that matter... and they would never help me do what i wanna do - thats AOL - everybody loves it and everybody hates it !
18-03-2003 at 04:37 AM
|
OptiSoft Level: Guest
Re: VB: How do i POST to HTTPS with custom headers (referer, cookie)
the cookie part you should be able to figure out on your own if your planning on coding this program.... the header part is a wee bit tricky:
headers = "Content-Type: application/x-www-form-urlencoded" & vbCrLf & "User-Agent: Internet Explorer 6.x" & vbCrLf & "Referer: http://www.optisoft.net/" & vbCrLf
Re: VB: How do i POST to HTTPS with custom headers (referer, cookie)
Have you got your solution? I am working on something similar to yours. I use piece of code like this
Dim IHTMLElementObj As IHTMLElement
If URL = "javascript:submitForm()" Then
For Each IHTMLElementObj In wbSSO.Document.All
If IHTMLElementObj.tagName = "FORM" Then
Debug.Print "==== Form name is: " & IHTMLElementObj.Name
If IHTMLElementObj.Name = "Login" Then
Debug.Print " I am in login form"
mAuth.mUsername = IHTMLElementObj.USER.value
mAuth.mPassword = IHTMLElementObj.PASSWORD.value
End If
End If
If IHTMLElementObj.tagName = "FRAME" Then
Debug.Print IHTMLElementObj.outerHTML
End If
Next
End If
End Sub
This is in before navigate2 event.
Basically, you just go into the form's input field and retrieve the values.
But I don't know how to mimic the click of "submit" button, do you get it?
20-05-2003 at 07:23 PM
|
win_dir Level: VB Guru Registered: 04-08-2002 Posts: 390
Re: VB: How do i POST to HTTPS with custom headers (referer, cookie)
Which controls/references have you used in this example, please specify.
Re: VB: How do i POST to HTTPS with custom headers (referer, cookie)
I am using the WebBrowser control
This control has a navigate (or navigate2) method so that you can use just like opening a web browser. However, if you want to do everything programatically and automatically, you need to mimic the behavior of using a web browser.
My sample code shows how to populate/retrieve information from the form of a page. Next step is to mimic the click of submit button, which I did not figure out how.
Any suggestions are appreciated.
22-05-2003 at 01:28 PM
|
mrAll Level: Guest
Re: VB: How do i POST to HTTPS with custom headers (referer, cookie)
~Bean~ Level: VB Guru Registered: 07-04-2003 Posts: 488
Re: VB: How do i POST to HTTPS with custom headers (referer, cookie)
not to be a pessimist or anything, and assuming it is actually possible to do what you want...I bet as soon as you get this coded AOL will put measures in place to stop it (version 9.0 available in every store near you soon! or just wait and they'll mail you a few at home..or you can take one of the ones you got in your mail at work home with you...or...)
Have you explored changing providers?
...from the little I know of web browsers/language/apps/programming/etc., I do know that AOL is biggest bunch of........
well, mama always said if you can't say aything nice...
(..........silence.............)
hey..........what am I doin in the internet apps forum anyways ?!?!?!...DOH!!
get me outta here.......................
~Bean~ <--AOL user since 1995
roflmao
____________________________
Eggheads unite! You have nothing to lose but your yolks.