Last active
May 28, 2016 07:25
-
-
Save khambadkone/7e28c9edc51ae50511751da97e656492 to your computer and use it in GitHub Desktop.
Check if a site contains a word
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Google does a great job searching for keywords on a site | |
# If there are none, their reponse always includes "did not match any documents" | |
import urllib2 | |
import sys | |
site = sys.argv[1] | |
word = sys.argv[2] | |
# need the user-agent so google wont return a 403 | |
headers = {'User-agent':'Mozilla/11.0'} | |
req = urllib2.Request('https://www.google.co.in/search?q='+site+'+site:'+word,None,headers) | |
site = urllib2.urlopen(req) | |
data = site.read() | |
if "did not match any documents" in data: | |
print "Not there" | |
else: | |
print "There" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment