python - download images with google customsearch api -
my question trivial. tried configure customsearch engine download first 10 results of google image. here python script. works except result far 1 of google image same parameter. can tell me miss?
# -*- coding: utf-8 -*- import os import sys urllib import fancyurlopener import urllib2 import simplejson apiclient.discovery import build class myopener(fancyurlopener): version = 'mozilla/5.0 (windows; u; windows nt 5.1; it; rv:1.8.1.11) gecko/20071127 firefox/2.0.0.11' myopener = myopener() service = build("customsearch", "v1", developerkey="** key **") res = service.cse().list( q='searchterm', cx='** cx**', searchtype='image', num=10, imgtype='photo', filetype='jpg', imgsize="xxlarge" ).execute() count=0 item in res['items']: myopener.retrieve(item['link'],str(count)) count=count+1
Comments
Post a Comment