- public static String get(String uri){
- System.setProperty("https.proxySet", "true");
- System.getProperties().put("https.proxyHost", ip);
- System.getProperties().put("https.proxyPort", port);
- Document doc = null;
- String agent="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)"
- + " Chrome/56.0.2924.87 Safari/537.36" ;
- try {
- doc = Jsoup.connect(uri).ignoreContentType(true)
- .userAgent(agent)
- // ignoreHttpErrors
- //这个很重要 否则会报HTTP error fetching URL. Status=404
- .ignoreHttpErrors(true) //这个很重要
- .timeout(3000).get();
- } catch (IOException e) {
- System.out.println(e.getMessage()+" **************** get");
- }
- if (doc!=null) {
- return doc.body().text();
- }
- return null;
- }
使用Jsoup加代理发送get请求
最新推荐文章于 2023-12-26 15:36:16 发布