Re: Set user agent for NSURL
Re: Set user agent for NSURL
- Subject: Re: Set user agent for NSURL
- From: John Pannell <email@hidden>
- Date: Mon, 17 Nov 2008 05:15:37 -0700
Hello I am working on a website crawler and I am needing to make a
user agent string so people who monitoring who visits can know
that my crawler visited.
It sounds like you're getting data just using NSURL.
You can get much more control (including specifying the agent)
using NSURLConnection and creating an NSURLRequest.
In case you are not used to such things, specifically you'll need an
NSMutableURLRequest.
Like this:
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:
[NSURL URLWithString:theURLYouWantToScrape]];
[request setValue:theNameOfYourUserAgent forHTTPHeaderField:@"User-
Agent"];
NSURLConnection *yourConnection = [NSURLConnection
connectionWithRequest:request delegate:self];
The setting of the header field can be tough to find in the docs.
Hope this helps!
John
John Pannell
Positive Spin Media
http://www.positivespinmedia.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden