[英]Jsoup library in Java - logging on Google
The question is just how should I write my code to receive just one cookie, which I could use for connecting to websites that require logging in? 问题是我应该如何编写代码以仅接收一个cookie,该cookie可用于连接到需要登录的网站?
Connection.Response res = Jsoup.connect("https://gmail.com")
.data(<all stuff for logging in>)
.execute();
And res.cookies()
would give me my session ID etc. res.cookies()
会给我我的会话ID等。
I tried this: 我尝试了这个:
String loginUrl = "https://accounts.google.com/Login?hl=pl#identifier";
Connection.Response res = Jsoup.connect(loginUrl)
.data("Email", MYMAIL)
.execute();
Connection.Response res2 = Jsoup.connect(loginUrl)
.cookies(res.cookies())
.data("Passwd", MYPASS)
.execute();
Document page = Jsoup
.connect("https://adwords.google.com/")
.cookies(res2.cookies())
.get();
System.out.println(page.toString());
And I don't see the page I want to see. 而且我没有看到我想要看到的页面。 Propably this shouldn't be working but I can't code anything better yet. 可能这不应该起作用,但是我还不能编写任何更好的代码。 It worked on t 它在t上起作用
Basically, my main target is to be able to extract data from AdWords using Java (I'm working with Eclipse). 基本上,我的主要目标是能够使用Java(我正在使用Eclipse)从AdWords提取数据。 The last obstacle is logging in. 最后的障碍是登录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.