-3

此代码返回网站的移动版本。如何获得桌面版本?

InputStreamReader page = new InputStreamReader(new URL('http://www.***.com/').openStream());
4

1 回答 1

5

使用与桌面浏览器匹配的用户代理

已编辑来源

URL url = new URL("http://www.clarku.edu/");
URLConnection connection = url.openConnection();
connection.addRequestProperty("User-Agent", "Mozilla/6.0 (Windows NT 6.2; WOW64; rv:16.0.1) Gecko/20121011 Firefox/16.0.1");

BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
于 2013-02-08T07:50:46.037 回答