Advertisement
Lulz-Tigre

getuas

Jul 10th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import urllib, sys
  4. from bs4 import BeautifulSoup
  5.  
  6. if len(sys.argv) <= 1:
  7.     print "No URL specified. Please supply a valid http://www.useragentstring.com/ UA list URL"
  8.     sys.exit(1)
  9.  
  10.  
  11. ua_url = sys.argv[1]
  12.  
  13. f = urllib.urlopen(ua_url)
  14.  
  15. html_doc = f.read()
  16.  
  17. soup = BeautifulSoup(html_doc)
  18.  
  19. liste = soup.find(id='liste')
  20.  
  21. uas = liste.find_all('li')
  22.  
  23. if len(uas) <= 0:
  24.     print "No UAs Found. Are you on http://www.useragentstring.com/ lists?"
  25.     sys.exit(1)
  26.  
  27.  
  28. for ua in uas:
  29.     ua_string = ua.get_text()
  30.     ua_string = ua_string.strip(' \t\n\r')
  31.     print ua_string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement