How to check if a url is indexed by google using Google Custom search API and Python? -
i need check if urls indexed google using python script , google custom search. i'd obtain in script same results obtain when browser google site:www.example.it. code is:
import urllib2 import json import pprint data = urllib2.urlopen('https://www.googleapis.com/customsearch/v1?key=aizasya3xnw1dooc4rjougc7sq1gltqvogalhqa&cx=017576662512468239146:omuauf_lfve&q=site:http://www.repubblica.it/politica/2014/04/07/news/governo_e_patto_su_italicum_brunetta_a_renzi_riforma_elettorale_entro_pasqua_o_si_dimetta-82947958/?ref=hrea-1') data=json.load(data) print data
the output of is:
{ u'kind': u'customsearch#search', u'queries': { u'request': [ { u'count': 10, u'cx': u'017576662512468239146:omuauf_lfve', u'inputencoding': u'utf8', u'outputencoding': u'utf8', u'safe': u'off', u'searchterms': u'site:http://www.repubblica.it/politica/2014/04/07/news/governo_e_patto_su_italicum_brunetta_a_renzi_riforma_elettorale_entro_pasqua_o_si_dimetta-82947958/?ref=hrea-1', u'title': u'google custom search - site:http://www.repubblica.it/politica/2014/04/07/news/governo_e_patto_su_italicum_brunetta_a_renzi_riforma_elettorale_entro_pasqua_o_si_dimetta-82947958/?ref=hrea-1', u'totalresults': u'0'}]}, u'searchinformation': { u'formattedsearchtime': u'0.55', u'formattedtotalresults': u'0', u'searchtime': 0.552849, u'totalresults': u'0'}, u'url': { u'template': u'https://www.googleapis.com/customsearch/v1?q={searchterms}&num={count?}&start={startindex?}&lr={language?}&safe={safe?}&cx={cx?}&cref={cref?}&sort={sort?}&filter={filter?}&gl={gl?}&cr={cr?}&googlehost={googlehost?}&c2coff={disablecntwtranslation?}&hq={hq?}&hl={hl?}&sitesearch={sitesearch?}&sitesearchfilter={sitesearchfilter?}&exactterms={exactterms?}&excludeterms={excludeterms?}&linksite={linksite?}&orterms={orterms?}&relatedsite={relatedsite?}&daterestrict={daterestrict?}&lowrange={lowrange?}&highrange={highrange?}&searchtype={searchtype}&filetype={filetype?}&rights={rights?}&imgsize={imgsize?}&imgtype={imgtype?}&imgcolortype={imgcolortype?}&imgdominantcolor={imgdominantcolor?}&alt=json', u'type': u'application/json'}}
as can see there no "items" while if google site:http://www.repubblica.it/politica/2014/04/07/news/governo_e_patto_su_italicum_brunetta_a_renzi_riforma_elettorale_entro_pasqua_o_si_dimetta-82947958/?ref=hrea-1 have @ least 1 item.
after various experiments seems google custom search doesn't work queries site:website.
do know solution or alternative problem? thanks.
with google cse specify site via cse configuration (corresponding 'cx' parameter) not via 'site:' query parameter. in 'basics' tab of cse should see section called "sites search".
Comments
Post a Comment