Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with Http Connect/PostFormData
I've been trying to grab a page from a site ( I need to log in first at
I use this:

Copy      Help
ARRAY(POSTFIELD) a.create(3)
a[0].name="signin-username"; a[0].value="my username"
a[1].name="signin-password"; a[1].value="my password"
a[2].name="btnLogin"; a[2].value="Login!";; (for login button, not sure if that's needed)

Http h.Connect(""); h.PostFormData("login" a)
str SourceLink; h.FileGet("view/id/1403030" SourceLink)

Am I doing something wrong? Are the missing "/", "http" and "www" correct? It doesn't log on, SourceLink shows up as the login page (with an error, can't login). Also the site has a https version so I tried above Http h.Connect("" "" "" 443), but now SourceLink becomes a blank page.

I copy paste below the relevant part of the login page's html, perhaps I'm not using the right parts for names/values? (I also used "username" and "password" without the "signin-" parts but still nothing). Thank you, I appreciate any help!

Copy      Help
<div class="form-row"><div class="form-label">
<label for="signin-username">Username</label>
</div><div class="form-field">
<input type="text" size="25" id="signin-username" name="username" value="my username" maxlength="100" />

<div class="form-row"><div class="form-label">
<label for="signin-password">Password</label>
</div><div class="form-field">
<input type="password" size="25" id="signin-password" name="password" maxlength="50" />

<div class="form-submit"><div class="form-field">
<a class="button" href="#" id="btnLogin"><span>Login!</span></a>
Look in HTML, maybe <form> action attribute is not "login". Also maybe <form> has onclick attribute, then PostFormData may not work.
Look what is response page, maybe shows an error.

Macro Macro1710
Copy      Help
Http h.Connect("")
h.PostAdd("username" "my username")
h.PostAdd("password" "my password")
str r
if(!h.PostFormData("login" 0 r)) end "failed"
out r ;;response page

str SourceLink; h.FileGet("view/id/1403030" SourceLink)
Thank you Gintaras.
The code didn't work and there's no error either. But you're right, form action on the page is actually

Copy      Help
<h1>Sign In</h1><form action="" method="post" id="loginForm"><fieldset>

So I have to use this?

Copy      Help
h.PostFormData("login/processLogin" a)

It doesn't work either. Since it's https I also used 443 (like below) but again the same blank result.

Copy      Help
Http h.Connect("" "" "" 443)

I'm not sure where to use the "post" method and "loginForm" id from above (if they are to be used, i played around a bit with no success)

Thanks for the patience.
Also try action "". Other <form> attributes are not used.
You mean the full link in here?

Copy      Help
h.PostFormData("" a)

Doesn't work either. With the full link above it doesn't find the page. With the link abbreviated (login/processLogin) it gives a page saying something like "you have a problem with cookies and logging, you shouldn't be here". While the initial link (login) it says somehing like "your configuration is outdated or not compatible".

I've read in an old thread you said postformdata often doesn't work. Is there any other way (perhaps we postformdata2?) or we just accept it's one of those times?

Probably will not work.

Can try to insert this before:
IntGetFile "" _s ;;here "" is the page with the login form
Maybe it will set cookies correctly.

Other way would be through web browser or web browser control. Enter name and password like user would do, and click the download link. But then probably will show "Download" dialog.
It didn't work again.

Yeah, I'll have to do it with the browser and long succesions of accessible objects commands, non-mouse clicks etc, as it's not really a file I want to download (I just said this for simplicity). I want to download 100+ pages/files, the macro to check text and links on the pages, then to download other pages, etc. Weekly. It was so easy before they changed their site, now it will get a bit messy! But I think it's possible.

Anyway, if you think of anything else, let me know. Thanks again for all your help!


Forum Jump:

Users browsing this thread: 1 Guest(s)