in reply to downloading images from a webpage
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: downloading images from a webpage
by Aldebaran (Curate) on Apr 07, 2012 at 18:33 UTC | |
that was my first tack, and I thought I was on the right track, but what I ended up with using getstore() was files that kind of thought they were jpg's and kind of thought they were html docs. Here's the script I used:
an ls command shows question marks:
and when I open up a jpg it looks like this:
I think the trick might be to find a way to define $params such that this works, but I haven't been able to do that yet. (I only get errors)
| [reply] [d/l] [select] |
by Aldebaran (Curate) on Apr 09, 2012 at 05:44 UTC | |
I finally got output, but it looks like a kid did it. I'd like to polish it up and be able to have a script that uses WWW::Mechanize more effectively.
How would I use chomp instead of $text =~ s/\s+//;? Nothing I tried worked. My failure with WWW::Mechanize was almost complete. The most I could get it to do was dump the names of the images to STDOUT. How could I re-write this to avoid all the nonsense with saving to a file which I then have to read? The syntax for $mech->images is: Lists all the images on the current page. Each image is a WWW::Mechanize::Image object. In list context, returns a list of all images. In scalar context, returns an array reference of all images. I tried a dozen different things, but I don't get why this is not list context:
| [reply] [d/l] [select] |
by blakew (Monk) on Apr 09, 2012 at 15:54 UTC | |
You do call images() in list context. What you're going to want to do is combine this with getstore to save your images:
| [reply] [d/l] |
by Aldebaran (Curate) on Apr 14, 2012 at 00:56 UTC | |
I really screwed up this thread with a lot of newbie mistakes, but I wanted to thank blake for helping me combine a couple of the things I've been trying to do here. I can't seem to do so where his reply was, but I would like him to see that his script improvements worked. Let me also state that I'm as far from national socialism ideologically as I could be: I support civil rights, union rights, democracy, and I'm a pacifist.
| [reply] [d/l] |