Let's say that I need to retrieve the HTML of a website making a Httpget
in my app. But, if the site has a mobile version of the content, I want this version and not the usual/desktop version (for instance, if you access http://techcrunch.com/ in your mobile you will get a diffent html that you will get if you access this website on your desktop)
I have made the following code:
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
request.setHeader("User-Agent", System.getProperty("http.agent"));
HttpResponse response = client.execute(request);
BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
String html = sb.toString();
but after that, the html
string contains the "desktop" version of the website and not the HTML for the mobile version. My intuition says that I only need to configure the "User-Agent" for the httpget, but it seems that I need to configre anything else.
Any help?