Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys
- import urllib2
- from BeautifulSoup import BeautifulSoup
- UA = "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4"
- def increment(i):
- request = urllib2.Request('https://www.google.com/search?q='+ i +'%2B1&btnG=Search')
- request.add_header('User-Agent', UA)
- result = urllib2.urlopen(request)
- soup = BeautifulSoup(result.read())
- return soup.findAll('h2', {'class': 'r'})[0].text.split(' = ')[1:][0]
- if __name__ == '__main__':
- print increment(sys.argv[1])
Advertisement
Add Comment
Please, Sign In to add comment