11import requests , random , threading as th
22from bs4 import BeautifulSoup as BS
3- from fake_useragent import UserAgent as UA
43from progress .bar import ChargingBar
4+ from tools .user_agents import r_ua
55
66def SPC (ip , port , login = None , password = None ):
7- ua = UA (). random
7+ ua = r_ua ()
88 ipp = ip + ':' + port
99 proxy_http = {'http' : 'http://' + ipp }
1010
@@ -146,7 +146,7 @@ def get(self):
146146 bar = ChargingBar ('Парсинг' , max = len (pr_b ))
147147
148148 # User-Agent
149- ua = UA ()
149+ ua = r_ua ()
150150
151151 # Summary sheet with proxy
152152 itog = {}
@@ -161,7 +161,7 @@ def get(self):
161161 for ct in url_list :
162162 can = False
163163 try :
164- response = requests .get (url_list [ct ], headers = {"User-Agent" : ua . random }, timeout = self .timeout )
164+ response = requests .get (url_list [ct ], headers = {"User-Agent" : ua }, timeout = self .timeout )
165165 can = True
166166 except :
167167 pass
@@ -193,7 +193,7 @@ def get(self):
193193 # -----------------------------------------------
194194 can = False
195195 try :
196- response = requests .get ("https://www.sslproxies.org" , headers = {"User-Agent" : ua . random }, timeout = self .timeout )
196+ response = requests .get ("https://www.sslproxies.org" , headers = {"User-Agent" : ua }, timeout = self .timeout )
197197 can = True
198198 except :
199199 pass
@@ -230,7 +230,7 @@ def get(self):
230230 if self .unknown == True :
231231 can = False
232232 try :
233- response = requests .get ("https://api.proxyscrape.com/v2/?request=displayproxies&protocol=http&timeout=5000&country=all&ssl=all&anonymity=all" , headers = {"User-Agent" : ua . random }, timeout = self .timeout )
233+ response = requests .get ("https://api.proxyscrape.com/v2/?request=displayproxies&protocol=http&timeout=5000&country=all&ssl=all&anonymity=all" , headers = {"User-Agent" : ua }, timeout = self .timeout )
234234 can = True
235235 except :
236236 pass
@@ -254,7 +254,7 @@ def get(self):
254254 col_page = 1
255255 can = False
256256 try :
257- result = requests .get ("https://proxylist.geonode.com/api/proxy-list?limit=50&page=1&sort_by=lastChecked&sort_type=desc&speed=medium&protocols=http%2Chttps" , headers = {"User-Agent" : ua . random }, timeout = self .timeout )
257+ result = requests .get ("https://proxylist.geonode.com/api/proxy-list?limit=50&page=1&sort_by=lastChecked&sort_type=desc&speed=medium&protocols=http%2Chttps" , headers = {"User-Agent" : ua }, timeout = self .timeout )
258258 can = True
259259 except :
260260 pass
@@ -269,7 +269,7 @@ def get(self):
269269 i = 1
270270 while i < col_page :
271271 try :
272- response = requests .get (f"https://proxylist.geonode.com/api/proxy-list?limit=50&page={ i } &sort_by=lastChecked&sort_type=desc&speed=medium&protocols=http%2Chttps" , headers = {"User-Agent" : ua . random }, timeout = 15 )
272+ response = requests .get (f"https://proxylist.geonode.com/api/proxy-list?limit=50&page={ i } &sort_by=lastChecked&sort_type=desc&speed=medium&protocols=http%2Chttps" , headers = {"User-Agent" : ua }, timeout = 15 )
273273 if response .status_code == 200 :
274274 for pr in response .json ()["data" ]:
275275 ip = pr ["ip" ]
0 commit comments