Google Free API

Input file at: https://dustycodes.wordpress.com/2011/11/14/input-uss/

import urllib
f=open("input.uss")
while(True):
	product_name=f.readline()
	if(product_name):
                product_name.strip()
                orig=product_name
                product_name.replace(' ','+')
		product_name.replace(',','%2c')
		google_search_url='https://www.googleapis.com/customsearch/v1?key=AIzaSyDbFnjndOj_hXgsw3MlaCevoUsIQ4egPMQ&client=google-csbe&cx=012749261079093371120:utxs7crkqqw&fields=items(link)&q='+product_name+'+reviews+rating+more:user_reviews+more:recent3+more:recent4+more:recent2'
		k = urllib.urlopen(google_search_url)
		urls = k.read()
		for x in range(0,10):
                        url = urls[urls.find('"link": "')+9:]
                        url = url[:url.find('"')]
                        content=urllib.urlopen(url).read()
                        if(content.find("reviews")>-1):
                                if(content.find(orig)>-1):
                                        print orig
                        urls=urls[urls.find(url)+len(url):]
                        
                           
	else:
		break
		
		
	
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: