URL url = new URL("****************"); StringBuffer html = new StringBuffer(); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", "Mozilla/31.0 (compatible; MSIE 10.0; Windows NT; DigExt)"); InputStreamReader isr = new InputStreamReader(conn.getInputStream(),"utf-8");
设一下请求属性就行了:
conn.setRequestProperty("User-Agent", "Mozilla/31.0 (compatible; MSIE 10.0; Windows NT; DigExt)");
时间: 2024-10-08 01:13:42