Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with Http Connect/PostFormData
#1
Hello,
I've been trying to grab a page from a site (http://yyy.com/view/id/1403030). I need to log in first at http://yyy.com/login
I use this:

Code:
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("yyy.com"); 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("yyy.com" "" "" 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!



Code:
Copy      Help
USERNAME
<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></div>

PASSWORD
<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></div>

BUTTON
<div class="form-submit"><div class="form-field">
<a class="button" href="#" id="btnLogin"><span>Login!</span></a>
</div></div>
#2
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
Code:
Copy      Help
out
Http h.Connect("yyy.com")
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)
#3
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

Code:
Copy      Help
<h1>Sign In</h1><form action="https://yyy.com/login/processLogin" method="post" id="loginForm"><fieldset>

So I have to use this?

Code:
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.

Code:
Copy      Help
Http h.Connect("yyy.com" "" "" 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.
#4
Also try action "https://yyy.com/login/processLogin". Other <form> attributes are not used.
#5
You mean the full link in here?

Code:
Copy      Help
h.PostFormData("https://yyy.com/login/processLogin" 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?

Thanks
#6
Probably will not work.

Can try to insert this before:
IntGetFile "https://yyy.com" _s ;;here "https://yyy.com" 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.
#7
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!

Alex


Forum Jump:


Users browsing this thread: 3 Guest(s)