Automatically input website user details

Just starting out? Need help? Post your questions and find answers here.
johnnyutah
User
User
Posts: 27
Joined: Sat Oct 16, 2004 1:25 pm

Automatically input website user details

Post by johnnyutah »

Hi

I'm trying to download a particular web page using the code below but can't access it as a username and password are required. The code does download an HTML page but it's the login screen. Is there any way to pass a username and password to the website using code?

Code: Select all

Procedure.s OpenURL(Url.s, OpenType.b)
  ; OpenURL procedure by ricardo 2003
  isLoop.b=1
  INET_RELOAD.l=$80000000
  hInet.l=0: hURL.l=0: Bytes.l=0
  Buffer.s=Space(2048)
  hInet = InternetOpen_("PB@INET", OpenType, #Null, #Null, 0)
  hURL = InternetOpenUrl_(hInet, Url, #Null, 0, INET_RELOAD, 0)
  Repeat
    Delay(1)
    InternetReadFile_(hURL, @Buffer, Len(Buffer), @Bytes)
    If Bytes = 0
      isLoop=0
    Else
      res.s = res + Left(Buffer, Bytes)
    EndIf
  Until isLoop=0
  InternetCloseHandle_(hURL)
  InternetCloseHandle_(hInet)
  ProcedureReturn res
EndProcedure

URL$ = "http://www.screenselect.co.uk/account/selection.html"
CreateFile(0,"F:\Downloads\ScreenSelect.html")
  WriteString(OpenURL(URL$, 1))
CloseFile(0)
End
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Hi johnnyutah,

If the form method is GET, then just stick the fields & values into the url, eg:
  • validationpage.asp?account=myNick&password=myPass
(or whatever the field name and value combos are).

Be sure to send all fields, including hidden and the submit button, as the validation page may check these.

If the form method is POST, then use the code Karbon gave us, here:

viewtopic.php?p=39187&highlight=https#39187

It is HTTPS but he has comments showing the HTTP values.

Fill the post string with:
  • account=myNick&password=myPass
or whatever.

Note there is no leading "?". Also, you may need to urlencode special characters in your account name, password, etc (but not the & and = symbols defining keys and values). Just use % and the hex value, eg, %2B for "+".
@}--`--,-- A rose by any other name ..
Post Reply