我有一些代码正在使用正在运行的JSOUP来搜索ESPN幻想联盟数据。不幸的是,在新赛季中,旧赛季的数据被移到了身份验证墙之后,我一直在使用ESPN进行身份验证。我已经使用chrome dev工具查看了登录标题/数据,但是无法成功进行身份验证。我的目标是从此请求中获取成功的cookie以传递给所有后续的GET请求。
public static Connection.Response login(String username, String password) throws IOException{
String url = "http://www.espn.com/fantasy/football/";
Connection connection1 = Jsoup.connect(url).userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6").method(Connection.Method.GET);
Connection.Response response = connection1.execute();
url = "https://ha.registerdisney.go.com/jgc/v5/client/ESPN-FANTASYLM-PROD/guest/login?langPref=en-US";
Connection.Response connection2 = Jsoup.connect(url)
.userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36")
.data("loginValue", username, "password", password)
.header("host", "ha.registerdisney.go.com")
.header("correlation-id", "dfc537c2-8fe0-40e2-8d72-04617d11a078")
.header("authorization", "APIKEY 3gC3ZEgR+6YLQc8/oNygcm37bXong2jhstiAui9FOMN8hng3MWMQklxUrRG3rUMDLOS0+2wMeZ59gdT1xoL1u25NUg==")
.header("content-type", "application/json")
.header("conversation-id", "45dde0a2-3097-4821-910c-e074caac97b1")
.header("Origin", "https://cdn.registerdisney.go.com")
.header("expires", "-1")
.cookies(response.cookies())
.method(Connection.Method.POST)
.execute();
我首先在url上使用get请求并将这些cookie传递给人类,并且相信我在请求中拥有所有必需的值,但却无法使其正常工作。任何建议都表示赞赏!