AttilaTheFun
AttilaTheFun

Reputation: 701

Request desktop html NSURLSession

I am trying to parse some metadata from the head tags of various websites on iOS. Unfortunately, some of those sites (namely Vimeo) do not send the same metadata when rendering the mobile page as they do the desktop one. I need to request the html for the desktop version from these sites. Is this possible with NSURLSession? Thanks in advance!

Upvotes: 1

Views: 83

Answers (1)

rmaddy
rmaddy

Reputation: 318824

You will need to set the User-Agent header in your NSURLRequest to a value that makes the website believe you are sending the request from a non-mobile device.

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: someURL]; 
[request setValue:@"some appropriate desktop user agent string" forHTTPHeaderField:@"User-Agent"];

The following site lists many possible user agent strings you can choose from.

Upvotes: 2

Related Questions