Spaces:
Sleeping
Sleeping
Update webscout.py
Browse files- webscout.py +15 -6
webscout.py
CHANGED
@@ -1816,22 +1816,31 @@ from termcolor import colored
|
|
1816 |
import time
|
1817 |
import random
|
1818 |
|
1819 |
-
|
1820 |
"""
|
1821 |
-
|
|
|
|
|
|
|
1822 |
"""
|
1823 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1824 |
def __init__(
|
1825 |
self,
|
1826 |
headers: Optional[Dict[str, str]] = None,
|
1827 |
proxy: Optional[str] = None,
|
1828 |
timeout: Optional[int] = 10,
|
1829 |
-
max_workers: int = 20
|
1830 |
):
|
1831 |
-
"""Initializes the GoogleS object."""
|
1832 |
self.proxy = proxy
|
1833 |
self.headers = headers if headers else {
|
1834 |
-
"User-Agent":
|
1835 |
}
|
1836 |
self.headers["Referer"] = "https://www.google.com/"
|
1837 |
self.client = requests.Session()
|
|
|
1816 |
import time
|
1817 |
import random
|
1818 |
|
1819 |
+
def get_useragent():
|
1820 |
"""
|
1821 |
+
Generates a random user agent string mimicking Lynx browser format.
|
1822 |
+
|
1823 |
+
Returns:
|
1824 |
+
str: A randomly generated Lynx user agent string.
|
1825 |
"""
|
1826 |
+
lynx_version = f"Lynx/{random.randint(2, 3)}.{random.randint(8, 9)}.{random.randint(0, 2)}"
|
1827 |
+
libwww_version = f"libwww-FM/{random.randint(2, 3)}.{random.randint(13, 15)}"
|
1828 |
+
ssl_mm_version = f"SSL-MM/{random.randint(1, 2)}.{random.randint(3, 5)}"
|
1829 |
+
openssl_version = f"OpenSSL/{random.randint(1, 3)}.{random.randint(0, 4)}.{random.randint(0, 9)}"
|
1830 |
+
return f"{lynx_version} {libwww_version} {ssl_mm_version} {openssl_version}"
|
1831 |
+
|
1832 |
+
class GoogleS:
|
1833 |
def __init__(
|
1834 |
self,
|
1835 |
headers: Optional[Dict[str, str]] = None,
|
1836 |
proxy: Optional[str] = None,
|
1837 |
timeout: Optional[int] = 10,
|
1838 |
+
max_workers: int = 20
|
1839 |
):
|
1840 |
+
"""Initializes the GoogleS object with Lynx user agent."""
|
1841 |
self.proxy = proxy
|
1842 |
self.headers = headers if headers else {
|
1843 |
+
"User-Agent": get_useragent() # Use Lynx user agent
|
1844 |
}
|
1845 |
self.headers["Referer"] = "https://www.google.com/"
|
1846 |
self.client = requests.Session()
|