String encoding = "gb2312"; URLConnection connection = (HttpURLConnection)url.openConnection(); connection.setRequestProperty("User-agent","Mozilla/4.0"); connection.setReadTimeout(10000); BufferedReader reade = new BufferedReader(new InputStreamReader( connection.getInputStream(), encoding)); String line = ""; String address = ""; String name = ""; String tel = ""; while ((line = reade.readLine()) != null) { System.out.println(new String(line));user-Agent是浏览器标识的意思,如果您ua设为无,网页会认为是一个未知设备在请求访问,因此就默认推送简版到设备。 如果改为默认/android/iphone时,网页会识别您的设备为安卓/苹果,因此就推送触屏版了。
爬虫-记录
最新推荐文章于 2022-02-06 09:16:10 发布