Fetching functions log info and warnings
This commit is contained in:
parent
87108ef446
commit
fe02eaea6f
@ -1,5 +1,6 @@
|
|||||||
"""Proxy harvester module"""
|
"""Proxy harvester module"""
|
||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
|
import logging
|
||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
@ -9,10 +10,12 @@ def fetch_list(url):
|
|||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
except requests.RequestException:
|
except requests.RequestException:
|
||||||
|
logging.warning(f'Error fetching proxies from {url}')
|
||||||
return []
|
return []
|
||||||
|
|
||||||
proxy_regex = r"(?:\b(?:[\S]+:)?(?:[\S]+)?@\b)?(?:\d{1,3}\.){3}\d{1,3}:\d+"
|
proxy_regex = r"(?:\b(?:[\S]+:)?(?:[\S]+)?@\b)?(?:\d{1,3}\.){3}\d{1,3}:\d+"
|
||||||
proxies = re.findall(proxy_regex, response.text)
|
proxies = re.findall(proxy_regex, response.text)
|
||||||
|
logging.info(f'Fetched {len(proxies)} proxies from {url}')
|
||||||
return proxies
|
return proxies
|
||||||
|
|
||||||
|
|
||||||
@ -30,6 +33,7 @@ def fetch_all(urls, max_workers=8):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
logging.info(f'Fetched {len(proxies)} proxies in total')
|
||||||
return proxies
|
return proxies
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user