0

Im trying to login into istockphoto using jsoup but give me always wrong pass, the user and pass are both correct

code

String user = "myUser";
String pass = "myPass";


Connection doc = Jsoup.connect("https://secure.istockphoto.com/sign-in/");

String token = doc.get().body().getElementById("signInFormtoken").val();
Response res = doc
     .data("signInFormtoken",token, "identity", user, "credential", pass, "submit", "Sign In"   )
     .method(Method.POST)
     .execute();

System.out.println(res.body());

Document doc2 = Jsoup.connect("http://www.istockphoto.com/my_uploads.php").cookies(res.cookies()).get();

System.out.println(doc2.title());

form code

<form id="signInForm" enctype="application/x-www-form-urlencoded" action="" method="post"><dl class="zend_form">

<input type="hidden" name="signInFormtoken" value="YToxOntzOjU6InRva2VuIjtzOjMyOiI1M2M5ZmNhZjBhZWZjOTVlZDA3ZDVkNTZlOTg5Y2VjYSI7fQ==" id="signInFormtoken">
<label for="identity" Id="identityLabel" class="optional">Email or Member Name</label>

<input type="text" name="identity" id="identity" value="">
<label for="credential" Id="credentialLabel" class="optional">Password</label>

<input type="password" name="credential" id="credential" value="">

<img id="signInSpinner" class="h mt8" src="https://i.istockimg.com/static/images/loading.gif">

<input type="submit" name="submit" id="sign-in-submit" value="Sign In">

<a id="lost-password-link" href="/istock_lostpassword.php" class="lostPasswordLink">Forgot your password?</a></dl></form>

The login page is https://secure.istockphoto.com/sign-in/

What am I doing wrong?

ashatte
  • 5,442
  • 8
  • 39
  • 50

1 Answers1

0

I suggest Selenium + PhantomJSDriver (Ghostdriver), which is used for GUI-less browser automation. With this you can easily navigate through the pages, select elements (you can select the flights), submit forms and also perform some scraping. Javascript is also supported.

You can got through the Selenium documentation here. You will have to download phantomjs.exe file.

A good tutorial forPhantomJSDriver is given in here

Config of PhantomJSDriver(from the tutorial):

DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true); // not really needed: JS enabled by default
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "C://phantomjs.exe");
caps.setCapability("takesScreenshot", true);
WebDriver driver = new PhantomJSDriver(caps);   
LittlePanda
  • 2,496
  • 1
  • 21
  • 33