I want to make an app where I can download pages for offline viewing. I have my app successfully downloading the page's html code. However, images on the page do not download.
So, I have no idea how I would go about
1: determining if the page has images on it
2: downloading those images
3: linking them into the local html file
Ok, thanks, but how do I parse the data for the HTML code?
Any way you want?
You could look for an HTML parser already ported to the iPhone platform (dunno if Apple provides one, don't think so) or port one yourself.
This is such a simple case that you could do ad-hoc parsing using regular expressions. As a practical matter, you will need to use regular expressions, as you will need to ignore white space, capitalization, etc. e.g. <img src="/something"> vs < IMG src = "something >
I'd match an image tag, then match the src attribute inside the image tag. Loop through and match the rest of the image tags.
You'll need to modify the image tags to point to your local copies.
I think you're going to find this quite a bit more complicated than you think, though, if you intend to download more than a single page in isolation. You might want to look for some free, open-source software to start with. HTTRACK does this, but, unfortunately, has a GPL license, which may be incompatible with the App Store.
You could look for an HTML parser already ported to the iPhone platform (dunno if Apple provides one, don't think so) or port one yourself.
This is such a simple case that you could do ad-hoc parsing using regular expressions. As a practical matter, you will need to use regular expressions, as you will need to ignore white space, capitalization, etc. e.g. <img src="/something"> vs < IMG src = "something >
I'd match an image tag, then match the src attribute inside the image tag. Loop through and match the rest of the image tags.
You'll need to modify the image tags to point to your local copies.
I think you're going to find this quite a bit more complicated than you think, though, if you intend to download more than a single page in isolation. You might want to look for some free, open-source software to start with. HTTRACK does this, but, unfortunately, has a GPL license, which may be incompatible with the App Store.
Huh, ok, thanks for your help. This is much more complicated than I thought, you are right.
did you ever deal with this? I'm in the exact same situation now. If you've managed to download images from web pages, will you please let me know how you did it? did you have to learn much HTML?