Im new here so please be patient :)
I know there is bunch questions of this type, but i do not found answear for this kind of problem. I'm trying to login to website but i have two problems. I will post source code below and after that i will explaint what is wrong.
Connection.Response loginForm = Jsoup.connect("http://ift.tt/2w1RcyK") .method(Connection.Method.GET) .execute();
//System.out.println(loginForm);
Document document = Jsoup.connect("http://ift.tt/2uRoxxP")
.userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36")
.data("cookieexists", "false")
.data("login_username", "login")
.data("login_password", "password")
.data("action", "login")
.cookies(loginForm.cookies())
.post();
System.out.println(document);
In this case i get below error:
> Exception in thread "main" org.jsoup.HttpStatusException: HTTP error fetching URL. Status=403, URL=http://ift.tt/2w1RdTk
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:682)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:629)
at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:261)
at org.jsoup.helper.HttpConnection.post(HttpConnection.java:256)
at test.Test_1.main(Test_1.java:89)
I want you to know that this website is working only after connecting to VPN so proxy settings are unnecessary here. Additional I turned off certificate validation in Java HTTPS Connections because this was also one of my problem. Any idea how to resolve whis problem?
I also tried to connect using method get(); instead of post(); - result below:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://ift.tt/kTyqzh">
<html>
<head>
<title>Login to Website</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<style type="text/css">
<!--
BODY, TABLE, TR, TD {font-family: Verdana, Arial, Helvetica, sans-
serif; font-size: 12px;}
A {text-decoration: none;}
A:active { text-decoration: none;}
A:hover {text-decoration: underline; color: #333333;}
A:visited {color: Blue;}
-->
</style>
<script type="text/javascript">if (top != self) {top.location.href =
self.location.href;}</script>
<script type="text/javascript">var csrfMagicToken =
"sid:2cab4af55d51696dff403441da56e8f7777b205d,1501588419";var csrfMagicName
=
"__csrf_magic";</script>
<script src="/website/include/csrf/csrf-magic.js" type="text/javascript">
</script>
</head>
<body onload="document.login.login_username.focus()">
<form name="login" method="post" action="graph_view.php">
<input type="hidden" name="__csrf_magic"
value="sid:2cab4af55d51696dff403441da56e8f7777b205d,1501588419">
<input type="hidden" name="action" value="login">
<table id="login" align="center">
<tbody>
<tr>
<td colspan="2">
<center>
<img src="/website/images/auth_login.gif" border="0" alt="">
</center></td>
</tr>
<tr style="height:10px;">
<td></td>
</tr>
<tr>
<td id="error" colspan="2"><font color="#FF0000"><strong>Invalid User
Name/Password Please Retype</strong></font></td>
</tr>
<tr style="height:10px;">
<td></td>
</tr>
<tr id="login_row">
<td colspan="2">Please enter your Website user name and password
below:</td>
</tr>
<tr style="height:10px;">
<td></td>
</tr>
<tr id="user_row">
<td>User Name:</td>
<td><input type="text" name="login_username" size="40" style="width:
295px;" value=""></td>
</tr>
<tr id="password_row">
<td>Password:</td>
<td><input type="password" name="login_password" size="40"
style="width: 295px;"></td>
</tr>
<tr style="height:10px;">
<td></td>
</tr>
<tr>
<td><input type="submit" value="Login"></td>
</tr>
</tbody>
</table>
</form>
<script type="text/javascript">CsrfMagic.end();</script>
</body>
</html>
In HTML code there is information "Invalid User Name/Password Please Retype" but i'm sure that provided credential are correct. I have no idea where is problem... I will be grateful for your help.
PS I need that to get image which is available only after login to the website.
Aucun commentaire:
Enregistrer un commentaire