Loading contents of URL in a string
Loading contents of URL in a string
- Subject: Loading contents of URL in a string
- From: Tito Ciuro <email@hidden>
- Date: Thu, 8 Dec 2005 00:32:40 -0500
Hello,
I'm trying to load the contents of a web page into an NSString for
further processing. I've tried several things, which sort of work,
but not entirely. I've tried something like this:
NSString *string = @"
http://...";
NSURL *url = [NSURL URLWithString:string];
NSData *data = [url resourceDataUsingCache:NO];
NSString *urlContents = [[[NSString alloc]initWith
Data:data
encoding:NSASCIIStringEncoding]autorelease];
NSString *otherURLContents = [NSString stringWithContentsOfURL:url];
If I use something like "
http://www.apple.com", no problem: both
urlContents and otherURLContents show the HTML source. However, if I
specify something like "
http://wwwa.accuweather.com/index-
forecast.asp?partner=accuweather&myadc=0&zipcode=94025&u=1", the
contents show up in this form:
\u008b \u00ed\u00bd`I\u0096%&/m\u00ca{J\u00f5J\u00d7\u00e0t
\u00a1\u0080`$\u00d8\u0090@\u00ec\u00c1\u0088\u00cd\u00e6\u0092
\u00eciG#)\u00ab*\u0081\u00caeVe]f@\u00cc\u00ed\u009d\u00bc\u00f7
\u00de{\u00ef\u00bd\u00f7\u00de{\u00ef\u00bd\u00f7\u00ba;
\u009dN'\u00f7\u00df\u00ff?\fdl\u00f6\u00ceJ\u00da\u00c9\u009e!\u0080
\u00aa\u00c8?~|?"\u00ff\u00efez\u0099\u00d7MQ-?\u00fbhw\u00bc
\u00f3\u00d1\u00efq\u00f4'\u008f\u00d7\u00a7_\u009e\u00bc\u00f9}^
\u009e\u00a6\u00f3
...
...
...
Why is that? If I display the page using Safari, its source can be
easily seen... what am I missing?
Thanks,
-- Tito _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden