mercredi 21 mars 2018

how to perform search operation effectivley on web scraped data using python

from googleapiclient.discovery 
import build
import pprint

my_api_key = "Google API key"
my_cse_id = "Custom Search Engine ID"

def google_search(search_term, api_key, cse_id, **kwargs):
    service = build("customsearch", "v1", developerKey=api_key)
    res = service.cse().list(q=search_term, cx=cse_id, **kwargs).execute()
    return res['items']

results = google_search(
    'stackoverflow site:en.wikipedia.org', my_api_key, my_cse_id, num=10)
for result in results:
    pprint.pprint(result)

this is my python code to retreive data from web using Google api,now i want to perform search operation effectively during printing of data in for loop.how should i implement search opeartion.




Aucun commentaire:

Enregistrer un commentaire