NSData doubt

Discussion in 'iOS Development' started by johnmabassa, May 7, 2009.

  1. johnmabassa

    johnmabassa Member

    Joined:
    Mar 16, 2009
    Messages:
    87
    Likes Received:
    0
    I am having an NSData Object and I am doing like this

    NSData *data = [[NSData alloc] initWithContentsOfURL:myURL].//myURL say www.google.com

    Now what i want to know is whether "data" will contain the entire web page (along with image) in it or it is just the html source of the page.

    -John
  2. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    It's just pure data. Try writing it to a file, then opening the file.
  3. johnmabassa

    johnmabassa Member

    Joined:
    Mar 16, 2009
    Messages:
    87
    Likes Received:
    0
    I wrote to a file doing a stringEncoding and i found it is just the plain source

    I was exploring a way to save webpage completely ........ as I mentioned in one of my previous post .... I was able to save the source and display it to the webview but it is just the plain source ( not getting any images). So I was exploring some another ways

    1. trying to save the page as webarchive (not yet found how to do it).

    2. Converting the entire site in to data:URL format, I got a class which does base64Encoding of NSData..... but since NSData is just the plain source it is of no use for me.

    Need to dig more into it Uhh!!

    Please Register or Log in to view images



    Thanks
    -John
  4. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    parse the html source for <img ..> tags, and download the images. but the page could have links to other pages, which would need to be downloaded etc... it's really never ending if you think about it. what you're trying to do is seriously almost or definately impossible.
  5. johnmabassa

    johnmabassa Member

    Joined:
    Mar 16, 2009
    Messages:
    87
    Likes Received:
    0
    I was trying to save articles from a site so that people can read it offline thats all. I am not caring much about the links with in the page, what I am caring is the text and the image...... some apps like instapaper and newyorktimes, iDownload etc are doing these things and I was trying to something similar.

    I am not much familiar with parsing.... I will try to see how to do it.

    Thanks,
    -John
  6. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    I have given this literally no thought whatsoever. I may however see if I can whip something up tomorrow *if I have time.*

Share This Page