Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsoup can';不要登录第页_Jsoup - Fatal编程技术网

Jsoup can';不要登录第页

Jsoup can';不要登录第页,jsoup,Jsoup,我有一个问题:我无法登录Betfair页面,Jsoup似乎还可以,但无法返回已登录页面:( //您可以尝试使用此用户名和密码进行测试 //用户名: //密码: //LoginUrl:lite.betfair.com/Login.do?s=000009z重定向默认值 //这是我的密码 Connection.Response res=Jsoup.connect(“https://lite.betfair.com/SLoginsubmit.do?s=000009z-重定向默认值&secure=true

我有一个问题:我无法登录Betfair页面,Jsoup似乎还可以,但无法返回已登录页面:(

//您可以尝试使用此用户名和密码进行测试
//用户名:
//密码:
//LoginUrl:lite.betfair.com/Login.do?s=000009z重定向默认值
//这是我的密码
Connection.Response res=Jsoup.connect(“https://lite.betfair.com/SLoginsubmit.do?s=000009z-重定向默认值&secure=true)
.data(“用户名”、“密码”、“密码”)
.method(method.POST)
.execute();
映射cookies=res.cookies();
连接=Jsoup.connect(“https://lite.betfair.com/Mybets.do?s=000209z");
对于(条目cookie:cookies.entrySet()){
cookie(cookie.getKey(),cookie.getValue());
}
Document=connection.get();
系统输出打印项次(文件);

谁能帮助我?

您必须连接到登录页面,并使用其cookies发送post命令。类似以下内容:

    Connection.Response response1 = Jsoup.connect("https://lite.betfair.com/Login.do?s=000009z-redirectDefault")
            .execute();
    Map<String, String> cookies = response1.cookies();

    Connection connection2 = Jsoup.connect("https://lite.betfair.com/SLoginsubmit.do?s=000009z-redirectDefault&secure=true")
               .data("username", "<redacted>")
               .data("password", "<redacted>")
               .method(Method.POST);

    for (Entry<String, String> cookie : cookies.entrySet()) {
        connection2.cookie(cookie.getKey(), cookie.getValue());
    }
    Response response2 = connection2.execute();
    cookies.putAll(response2.cookies());

    Connection connection3 = Jsoup.connect("https://lite.betfair.com/Mybets.do?s=000209z");
    for (Entry<String, String> cookie : cookies.entrySet()) {
        connection3.cookie(cookie.getKey(), cookie.getValue());
    }

    Document document = connection3.get();
    System.out.println(document);
Connection.Response-response1=Jsoup.connect(“https://lite.betfair.com/Login.do?s=000009z-重定向默认值“)
.execute();
映射cookies=response1.cookies();
连接connection2=Jsoup.connect(“https://lite.betfair.com/SLoginsubmit.do?s=000009z-重定向默认值&secure=true)
.data(“用户名”,“”)
.data(“密码”,“密码”)
.方法(方法.职位);
对于(条目cookie:cookies.entrySet()){
connection2.cookie(cookie.getKey(),cookie.getValue());
}
Response response2=connection2.execute();
cookies.putAll(response2.cookies());
连接connection3=Jsoup.connect(“https://lite.betfair.com/Mybets.do?s=000209z");
对于(条目cookie:cookies.entrySet()){
connection3.cookie(cookie.getKey(),cookie.getValue());
}
Document=connection3.get();
系统输出打印项次(文件);

我在连接另一个页面时使用了您的代码,它第一次起作用。因此,您帮助了我,我尝试帮助您。:

您必须连接到登录页面,并使用其Cookie来执行post命令。大概是这样的:

    Connection.Response response1 = Jsoup.connect("https://lite.betfair.com/Login.do?s=000009z-redirectDefault")
            .execute();
    Map<String, String> cookies = response1.cookies();

    Connection connection2 = Jsoup.connect("https://lite.betfair.com/SLoginsubmit.do?s=000009z-redirectDefault&secure=true")
               .data("username", "<redacted>")
               .data("password", "<redacted>")
               .method(Method.POST);

    for (Entry<String, String> cookie : cookies.entrySet()) {
        connection2.cookie(cookie.getKey(), cookie.getValue());
    }
    Response response2 = connection2.execute();
    cookies.putAll(response2.cookies());

    Connection connection3 = Jsoup.connect("https://lite.betfair.com/Mybets.do?s=000209z");
    for (Entry<String, String> cookie : cookies.entrySet()) {
        connection3.cookie(cookie.getKey(), cookie.getValue());
    }

    Document document = connection3.get();
    System.out.println(document);
Connection.Response-response1=Jsoup.connect(“https://lite.betfair.com/Login.do?s=000009z-重定向默认值“)
.execute();
映射cookies=response1.cookies();
连接connection2=Jsoup.connect(“https://lite.betfair.com/SLoginsubmit.do?s=000009z-重定向默认值&secure=true)
.data(“用户名”,“”)
.data(“密码”,“密码”)
.方法(方法.职位);
对于(条目cookie:cookies.entrySet()){
connection2.cookie(cookie.getKey(),cookie.getValue());
}
Response response2=connection2.execute();
cookies.putAll(response2.cookies());
连接connection3=Jsoup.connect(“https://lite.betfair.com/Mybets.do?s=000209z");
对于(条目cookie:cookies.entrySet()){
connection3.cookie(cookie.getKey(),cookie.getValue());
}
Document=connection3.get();
系统输出打印项次(文件);

我顺便用了你的代码来连接另一个页面,第一次就成功了。所以你帮了我,我试着帮你。:)

您只需知道Cookie或SessionName的名称,就可以使用它登录

Response res = Jsoup.connect("https://lite.betfair.com/SLoginsubmit.do?s=000009z-rredirectDefault&secure=true")
                .method(Method.GET)
                .timeout(10000)
                .execute();

        sessionID = res.cookie("JSESSIONID");//her put the SessionName for website 
现在你有了网站的SessionName,你需要填写它

String username="your username";
String password="your pass";

Jsoup.connect("https://lite.betfair.com/SLoginsubmit.do?s=000009z-redirectDefault&secure=true")
                .data("login:username", username, "login:password", password, "login:loginImg", "", "login", "login")
                .cookie("JSESSIONID", sessionID)
                .method(Method.POST)
                .timeout(10000)
                .execute();// now you have SessionName and you can use it for any page in website


Document doc = Jsoup.connect("https://lite.betfair.com/Mybets.do?s=000209z")
                .cookie("JSESSIONID", sessionID)
                .timeout(10000)
                .get();// her to open any page with SessionName you have it
现在,您只需在文档中添加好的标记,即可从中获取数据

System.out.println(doc.body().text());

您只需要知道Cookie或SessionName的名称,然后就可以使用它登录

Response res = Jsoup.connect("https://lite.betfair.com/SLoginsubmit.do?s=000009z-rredirectDefault&secure=true")
                .method(Method.GET)
                .timeout(10000)
                .execute();

        sessionID = res.cookie("JSESSIONID");//her put the SessionName for website 
现在你有了网站的SessionName,你需要填写它

String username="your username";
String password="your pass";

Jsoup.connect("https://lite.betfair.com/SLoginsubmit.do?s=000009z-redirectDefault&secure=true")
                .data("login:username", username, "login:password", password, "login:loginImg", "", "login", "login")
                .cookie("JSESSIONID", sessionID)
                .method(Method.POST)
                .timeout(10000)
                .execute();// now you have SessionName and you can use it for any page in website


Document doc = Jsoup.connect("https://lite.betfair.com/Mybets.do?s=000209z")
                .cookie("JSESSIONID", sessionID)
                .timeout(10000)
                .get();// her to open any page with SessionName you have it
现在,您只需在文档中添加好的标记,即可从中获取数据

System.out.println(doc.body().text());

注意:网站的会话名称您可以这样知道: 登录到您的网站,您需要知道会话名称或cookies 然后在登录后在URL字段中写入此命令

javascript:void(alert(document.cookie))

然后获取会话名称

注意:网站的会话名称您可以这样知道: 登录到您的网站,您需要知道会话名称或cookies 然后在登录后在URL字段中写入此命令

javascript:void(alert(document.cookie))
然后获取会话名称