Link to home
Start Free TrialLog in
Avatar of Gotenks78
Gotenks78

asked on

Open a password protected webpage...

Hi ! :)

My problem is relatively easy...

I've to download a webpage from a site where you cannot enter before you've logged in, with username and password...

For now i log in and after launch my program who download the page...

Theres a mode to make my program log in ?

I've already tryed to use http://user:password@www.somethi.ng but doesn't work...

Please, help me :)
Avatar of vt45
vt45

Have you tried using the document object model and then doing something like this:

document.txtUserName.text = "user"
document.txtPassword.text = "password"
document.form1.submit()

There's a couple options.  You can use APIs or the "Microsoft Internet Transfer Control" component -- which I prefer.

I'll explain the Internet Transfer Control (inet) method.  If you'd rather use APIs, check out:
http://support.microsoft.com/default.aspx?scid=KB;en-us;q167706

You'll need to figure out what the username and password variables are called in the HTML.  Let's say they are as follows:
<input type="text" name="uname">
<input type="password" name="pword">

strFormData = "uname=" & strUname & "&pword=" & strPword
strURL = "http://www.somethi.ng"

Inet1.Execute strURL, "Post", strFormData, _
"Content-Type: application/x-www-form-urlencoded"

If it's one of those webpages that pops up an authentication box and not a simple html form, try setting the username and password fields in the inet control and sending it a request.
Avatar of Gotenks78

ASKER

Nothing to do...

I've tryed the two solutions but i continue to get a page who request autentication.

On the first post i've missed some information...

I'm already using the internet control. Tryed using the username and password property of the ocx but always the same result.

I've tryed he method of eric0213 but i always get the same page...

Tell me what information do u need to try to help me :-)

This is the code i've used:

Private Sub mnuUpdate_Click()
Dim Wpage() As Byte
Const FName = "c:\wpage.csv"
  Net.Execute "http://www.somethi.ng/home.asp", "Post", "?CodiceUtente=XXXXXXXX&pword=xxxxxxxxxxxx", "Content-Type: application/x-www-form-urlencoded"
  Pagina = Net.OpenURL("http://www.somethi.ng/members.asp?contentype=txt")
  If Dir(FName) <> "" Then
    Kill FName
  End If
  Open FName For Binary Access Write As #4
    Put #4, , Wpage()
  Close #4
End Sub

Thanks again boys :)

Gotenks78
Avatar of DanRollins
Hi Gotenks78,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

Gotenks78, Please DO NOT accept THIS comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
ASKER CERTIFIED SOLUTION
Avatar of SpideyMod
SpideyMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial