resurtm

Untitled

Apr 1st, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import sys
  4. import urllib2
  5. from BeautifulSoup import BeautifulSoup
  6.  
  7. 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"
  8.  
  9. def increment(i):
  10.     request = urllib2.Request('https://www.google.com/search?q='+ i +'%2B1&btnG=Search')
  11.     request.add_header('User-Agent', UA)
  12.     result = urllib2.urlopen(request)
  13.     soup = BeautifulSoup(result.read())
  14.     return soup.findAll('h2', {'class': 'r'})[0].text.split(' = ')[1:][0]
  15.  
  16. if __name__ == '__main__':
  17.     print increment(sys.argv[1])
Advertisement
Add Comment
Please, Sign In to add comment