1. 程式人生 > >java.net.ProtocolException: Server redirected too many times (20)

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