Jump to content

how to download pics from google picsearch?


Recommended Posts

hi,

i`m trying to write an app to load the pics on the result page from google pics, but don`t know how to do this.

i`m new to autoit and have only little experience in programming.

let me first explain what my app should do.

i use the windows media center and the addin mediabrowser. mediabrowser can display actorimages but imdb and tvdb do not have all pictures available.

so i decided to wirte my app to get nearly all actors with pics of them. it reads a list of actors and asks google for pictures matchin the acors name.

the IE windows opens... and the resultspage is shown... OK

but what now and how can i run it without an IE window that opens every time. atm. i have over 4000 actor in the list. 4000 windows will kill my PC.

here is my code... it`s not much.

#include <IE.au3>

$file = FileOpen("noimage.txt",0)                                           ;liste in file wird geöffnet

While 1     
    $line = FileReadLine($file)                                             ;gelesene zeile ist variable
    If @error = -1 Then ExitLoop                                            ;wenn EOF dann ende
        DirCreate("G:\Filmliste\test\" & $line)                             ;ordner mit zeilenname erstellen
        $oIE = _IECreate ("http://www.google.de/imghp?hl=de&tab=wi")        ;ie instanz mit definierter webseite öffnen
        $oForm = _IEFormGetObjByName ($oIE, "f")
        $oQuery = _IEFormElementGetObjByName ($oForm, "q")
        _IEFormElementSetValue ($oQuery, ""& $line)                         ; $line ins suchfeld eingeben
        _IEFormSubmit ($oForm)                                              ;such das
        MsgBox(0, "Line read:", $line)                                      ;ausgabe des namens in messagebox damit es kein killer bot wird :-)
Wend

FileClose($file)                                                            ;file schliessen

the noimage.txt:

Barbara O'Neil
Kenneth Tobey
Raymond Greenleaf
Griff Barnett
Tom Vaughan
Nectar Rose
Babak Tafti
Bronwen Hughes
Tyra Ferrell
Maya Angelou
Che J. Avery
Lloyd Avery II
Maia Campbell
Michael Colyar
Kina Cosper
Dina D.
James Deeth
...
...
...

summary:

done

read lines of noimage.txt

create folder with content of the line

post on google and get resulst

not done

download pics to the folder

run without IE window

how do i do this????

any hints?

thanks

Link to comment
Share on other sites

Welcome to the forums Maximus1.

This doesn't look to be too hard.

I have created a sample script that will create an array of all images on a google search page.

#include <IE.au3>
#include <Array.au3>
Global $aOut[1][2]
$count = 0

$sTerm = "apple+cake" ;URL Friendly.  I.E spaces become + etc.
$sURL = "http://images.google.com/images?q=" & $sTerm ; Make the URL

;Open the IE
$oIE = _IECreate ($sURL, 0, 0, 1, 0)

;Get all images on the page
$oImgs = _IEImgGetCollection ($oIE)
;Get Number of images
$iNumImg = @extended

;Resize the array
ReDim $aOut[$iNumImg][2]

;Loop through the collection of images
For $oImg In $oImgs
    ;Check if image is a thumbnail (gstatic.com"
    If StringInStr ($oImg.src, "gstatic") Then
        ;get the source URL
        $string = StringSplit ($oImg.src, ":http", 1)
        ;Yes, count += 1
        $count +=1
        $aOut[$count][0] = $oImg.src
        $aOut[$count][1] = "http" & $string[2]
    EndIf
Next

;Set the [0][0] element to be the number of images
$aOut[0][0] = $count
;Resize to only have the images we need
ReDim $aOut[$count+1][2]

;Display
_ArrayDisplay ($aOut)

From there you should be able to work out how to download an image.

Link to comment
Share on other sites

  • 1 year later...

It looks like the script suggested does not work on the current Google Image search web site. The array returned is empty.

Looking at the source code of the search results page on google image search web site, I did not find the URL for each image. It looks like they are in a DIV now.

Could anybody please help with that?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...