Re: Downloading html page
Re: Downloading html page
- Subject: Re: Downloading html page
- From: Brendan Younger <email@hidden>
- Date: Fri, 17 Aug 2001 15:42:17 -0500
On Tuesday, August 14, 2001, at 02:19 AM, Drew McCormack wrote:
On Tuesday, August 14, 2001, at 02:28 , Brendan Younger wrote:
On Monday, August 13, 2001, at 02:09 PM, email@hidden wrote:
I wish to download a HTML page from yahoo finance. I have come up
with the following code:
NSString *dataAsString;
dataAsString = [NSString stringWithContentsOfURL:[NSURL URLWithString:
@"http://chart.yahoo.com/t?a=02&b=01&c=01&d=02&e=20&f=01&g=d&s=itwo&y=0&
z=
itwo"]];
NSLog(dataAsString);
When I try this, nothing is written to the log. If I put another URL,
like "http://www.apple.com/quicktime" in, it works fine, and I get
the html written to the log. Can anyone think why this wouldn't work?
Also, if I copy the URL into a browser, I get the correct web page.
Help would be much appreciated.
Drew McCormack
It's a dynamic page and as such there's probably a re-direct or other
trickery going on. Their web server probably parses the url and sends
a separate stream of HTML from somewhere else. I don't think a simple
NSURL will get you what you need.
Brendan Younger
You couldn't give me a clue as to what I might need to do, and where I
could find out how to do it, could you? As you've probably already
established, I'm no networking guru, and I thought that if my browser
could request and download a URL, cocoa could too. I was obviously
wrong.
Cheers,
Drew McCormack
I too have no idea how to handle this sort of stuff. You might try
ftp://ftp.omnigroup.com/pub/software/Source/MacOSX/Frameworks/OmniNetworking-2001-06-26.
tar.gz but from the description on the Omni page, it may take some more
doing to get HTTP working on it. The W3C (World Wide Web Consortium)
has lots of documentation and some UNIX source code that may do the
trick, but IIRC, their source code is like any other big, massive, huge
project's; it's large and difficult to learn and could probably have
been implemented in a much nicer fashion if anyone who wrote it had any
aesthetic sense. (Unlike us, the artists and bohemian's of the IT
world =) ). Good luck.
Brendan Younger