forked from tamimibrahim17/List-of-user-agents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser-agent.py
42 lines (29 loc) · 800 Bytes
/
user-agent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import requests as req
from bs4 import BeautifulSoup
import time
url = 'http://www.useragentstring.com/pages/useragentstring.php?name=Firefox'
def save(br,ua):
file = br+'.txt'
with open(file,'a') as f:
f.write(ua+'\n')
def getUa(br):
url = 'http://www.useragentstring.com/pages/useragentstring.php?name='+br
r = req.get(url)
if r.status_code == 200:
soup = BeautifulSoup(r.content,'html.parser')
else:
soup = False
if soup:
div = soup.find('div',{'id':'liste'})
lnk = div.findAll('a')
for i in lnk:
try:
save(br,i.text)
except:
print('no ua')
else:
print('No soup for '+br)
lst = ['Firefox','Internet+Explorer','Opera','Safari','Chrome','Edge','Android+Webkit+Browser']
for i in lst:
getUa(i)
time.sleep(20)