Skip to content

Instantly share code, notes, and snippets.

@robertocommit
Created March 28, 2018 07:55
Show Gist options
  • Save robertocommit/e56e8869b66d5667929e9fea070b2f77 to your computer and use it in GitHub Desktop.
Save robertocommit/e56e8869b66d5667929e9fea070b2f77 to your computer and use it in GitHub Desktop.
Get a full list of User Agents in a csv file
from bs4 import BeautifulSoup
import requests
response = requests.get('http://www.useragentstring.com/pages/useragentstring.php?name=All').text.encode('utf-8')
soup = BeautifulSoup(response, 'html.parser')
fd = open('user_agents.csv','a')
for user_agent in soup.findAll('li'):
fd.write(user_agent.get_text() + '\n')
fd.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment