ebvtrnog
ebvtrnog

Reputation: 4377

Mobile version of a website in C#

I know how to get a HTML code of a site. Just that:

string urlAddress = "http://google.com";

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlAddress);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

if (response.StatusCode == HttpStatusCode.OK)
{
  Stream receiveStream = response.GetResponseStream();
  StreamReader readStream = null;

  if (response.CharacterSet == null)
  {
     readStream = new StreamReader(receiveStream);
  }
  else
  {
     readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
  }

  string data = readStream.ReadToEnd();

  response.Close();
  readStream.Close();
}

But what can I do to download the mobile version of this site?

Upvotes: 0

Views: 240

Answers (1)

Rob Conklin
Rob Conklin

Reputation: 9446

Many sites use responsive designs to allow the mobile and the full-browser sites to be the same one.

Others have a bit of javascript that detects your platform, and redirects you to the mobile site based on your agent string. Regardless, it's just another site, and you need to know the URL of that site to get it.

You can try some common patterns, like replacing the www. with m. m.weather.com instead of www.weather.com. But there is no real enforcement of this.

Upvotes: 2

Related Questions