Page 1 of 1

corrupted picture from google (wget)

Posted: Sat Nov 15, 2014 7:56 pm
by thalastplaya
Hello, I am fairly new to wget, but I am trying to write my own script. The script should get the first picture from google image based on a searh term.

I use the following:

Code: Select all

wget -U chrome -O test.jpg http://images.google.com/images?q=hotdog\&as_filetype=jpg
It does download a file, but not an image. It appears to be the html file?

Can any one help?

This is the log from one of my tries:

Code: Select all

--2014-11-15 20:14:12--  http://images.google.com/images?q=hotdog&as_filetype=jpg
Resolving images.google.com (images.google.com)... 212.10.212.121, 212.10.212.123, 212.10.212.79, ...
Connecting to images.google.com (images.google.com)|212.10.212.121|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://images.google.com/images?q=hotdog&tbm=isch&tbs=ift:jpg [following]
--2014-11-15 20:14:13--  http://images.google.com/images?q=hotdog&tbm=isch&tbs=ift:jpg
Reusing existing connection to images.google.com:80.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘test.jpg’


    [  <=>                                                                        ] 38,782       112KB/s   in 0.3s   


2014-11-15 20:14:13 (112 KB/s) - ‘test.jpg’ saved [38782]

Re: corrupted picture from google (wget)

Posted: Sat Nov 15, 2014 10:27 pm
by B.Goode
I suggest it is probably your search url that is wrong - if I plug that url straight into a browser I get a Google image search page back with a number of images, not a single .jpg which is what you seem to be expecting. That would explain you getting html as the source of the page.

Re: corrupted picture from google (wget)

Posted: Sun Nov 16, 2014 10:39 am
by thalastplaya
You're right.. Do you have any idea how you get the first picture?