Created
March 28, 2018 07:55
-
-
Save robertocommit/e56e8869b66d5667929e9fea070b2f77 to your computer and use it in GitHub Desktop.
Get a full list of User Agents in a csv file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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