java 根据 url 读取网页内容 遇到403问题

		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)");

你可能感兴趣的:(JAVA)