[英]Logging in to pastebin using Jsoup
我正在嘗試連接到pastebin並登錄。 運行此命令時,HTML不會顯示我已登錄,並且我的個人資料ID不在腳本中的任何位置。
Response loginResponse;
Document cur = null;
Map<String, String> loginCookies;
loginResponse = Jsoup.connect("http://www.pastebin.com/login.php")
.data("user_name", name)
.data("user_password", pwrd)
.data("submit", "Login")
.method(Method.POST)
.execute();
if (loginResponse != null)
{
loginCookies = loginResponse.cookies();
try
{
cur = Jsoup.connect("http://www.pastebin.com")
.cookies(loginCookies).get();
} catch (Exception e) {
e.printStackTrace();
}
for (Map.Entry<String, String> entry : loginCookies.entrySet())
{
System.out.println(entry.getKey() + "/" + entry.getValue());
}
String s = cur.body().html();
System.out.println(cur.body().html());
System.out.println(cur.body().html().contains("Arhowk"));
}
我相信所有數據字段都是正確的,php顯示正在使用POST方法,應該沒問題。 我對此還很陌生,我看到了很多有答案的頁面,但沒有看到任何解決此問題的解決方案。
嘗試像瀏覽器一樣;)
打開頁面:
loginResponse = Jsoup.connect("http://www.pastebin.com/login.php") .method(Connection.Method.GET) .execute();
登錄
loginResponse = Jsoup.connect("http://www.pastebin.com/login.php") .data("submit_hidden", "submit_hidden") .data("user_name", name) .data("user_password", pwrd) .data("submit", "Login") .cookies(loginResponse.cookies()) // pass cookies .method(Method.POST) .execute();
結束
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.