网页爬虫时,原来正常的代码,可能是因为网站做了cookie校验处理,报异常:java.net.ProtocolException: Server redirected too many times 

表示没有检查到cookie,一直循环重定向。

 在代码中加入蓝色的代码解决:

CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
URL realUrl= new URL(url); 
con = (HttpURLConnection) realUrl.openConnection();

相关文章:

  • 2021-07-10
  • 2022-01-16
  • 2021-09-14
  • 2021-07-04
  • 2021-10-11
  • 2021-11-13
  • 2022-03-06
猜你喜欢
  • 2021-12-06
  • 2021-05-14
  • 2021-06-15
  • 2021-05-27
相关资源
相似解决方案