java.net.ProtocolException: Server redirected too many times (20)

在做网页爬虫的时候,之前一切正常,后来可能是网站做了cookie校验处理,报异常:java.net.ProtocolException: Server redirected too many times (20)

在URL url = new URL(url);   之前写入这一段 就好了

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

原文:https://blog.csdn.net/qq_34670293/article/details/78041059 
 

你可能感兴趣的:(java)