Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-03-2009, 09:18 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 109
brian515 is on a distinguished road
Default Download images from the web

Hi,

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

Thanks in advance!
brian515 is offline   Reply With Quote
Old 05-03-2009, 09:22 AM   #2 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: San Diego, CA
Posts: 406
jtara is on a distinguished road
Default

I'd start by learning HTML. Then, the solution would be obvious. You basically just stated it.
jtara is offline   Reply With Quote
Old 05-03-2009, 09:27 AM   #3 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 109
brian515 is on a distinguished road
Default

Quote:
Originally Posted by jtara View Post
I'd start by learning HTML. Then, the solution would be obvious. You basically just stated it.
Ok, thanks, but how do I parse the data for the HTML code?
brian515 is offline   Reply With Quote
Old 05-03-2009, 09:49 AM   #4 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: San Diego, CA
Posts: 406
jtara is on a distinguished road
Default

Quote:
Originally Posted by brian515 View Post
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.

Last edited by jtara; 05-03-2009 at 09:56 AM.
jtara is offline   Reply With Quote
Old 05-03-2009, 10:02 AM   #5 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 109
brian515 is on a distinguished road
Default

Quote:
Originally Posted by jtara View Post
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.
Huh, ok, thanks for your help. This is much more complicated than I thought, you are right.
brian515 is offline   Reply With Quote
Old 05-03-2009, 10:19 AM   #6 (permalink)
Former NeXTStep Developer
 
Join Date: Mar 2009
Posts: 997
FlyingDiver will become famous soon enough
Default

You might investigate using a UIWebView to "load" the page, even if the web view isn't visible. Then you could try saving the webview somehow.

Trying to do it by parsing the HTML is basically replicating a large part of what UIWebView does.

joe
FlyingDiver is offline   Reply With Quote
Old 05-03-2009, 10:23 AM   #7 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 109
brian515 is on a distinguished road
Default

Quote:
Originally Posted by FlyingDiver View Post
You might investigate using a UIWebView to "load" the page, even if the web view isn't visible. Then you could try saving the webview somehow.

Trying to do it by parsing the HTML is basically replicating a large part of what UIWebView does.

joe
That was actually my original plan, but I thought that this may be easier and less bloated. I guess I was wrong.
brian515 is offline   Reply With Quote
Old 07-10-2010, 06:50 PM   #8 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 2
mona777 is on a distinguished road
Default

Brian,

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?

Many thanks

Last edited by mona777; 07-15-2010 at 07:20 PM.
mona777 is offline   Reply With Quote
Reply

Bookmarks

Tags
download, html, images, internet, offline

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 316
8 members and 308 guests
blueorb, givensur, guusleijsten, jbro, mer10, n00b, SLIC, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,880
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:04 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0