user-agents.py 471 B

12345678910111213
  1. #!/usr/bin/env python
  2. import requests
  3. import re
  4. headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20121201 icecat/17.0.1'}
  5. data = str(requests.get("https://user-agents.net/random",headers=headers).content)
  6. #user_agents = re.findall('<a href="/string/.+?">.+?</a>',data)
  7. link = re.findall('<a href="/string/.+?</a>(.+?)</a>',data)
  8. cleaner = re.compile('<.*?>')
  9. final = re.sub(cleaner, '', link[0])
  10. print(final.replace("\\n","").replace("\\t",""))