java—尝试使用jsoup进行刮取,但它要求启用Cookie

svujldwt  于 2021-07-07  发布在  Java
关注(0)|答案(0)|浏览(170)

与jsoup建立url连接后,返回:

Please enable cookies</h2> 
<p> This website is using a security service to protect itself from online attacks. The service requires full cookie support in order to view the website. </p> 
<p>Please enable cookies on your browser and try again.</p>

在建立连接之前,我已经在获取cookies:

Connection.Response res = Jsoup.connect(url)
            .method(Connection.Method.POST)
            .timeout(30000)
            .execute();
    Map<String, String> cookies = res.cookies();

然后我把它传递给jsoup连接。

Document document =  Jsoup.connect(url)
            .cookies(cookies)
            .ignoreHttpErrors(true)
            .timeout(30000)
            .get();

我做错什么了?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题