44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
|
|
import httpx
|
||
|
|
import ssl
|
||
|
|
|
||
|
|
def test_libgen_ssl():
|
||
|
|
url = "https://libgen.li/series.php?id=577851"
|
||
|
|
headers = {
|
||
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
|
||
|
|
}
|
||
|
|
|
||
|
|
print(f"Testing connection to {url} with httpx...")
|
||
|
|
try:
|
||
|
|
with httpx.Client(verify=True, headers=headers, timeout=30.0) as client:
|
||
|
|
resp = client.get(url)
|
||
|
|
print(f"Status: {resp.status_code}")
|
||
|
|
print(f"Content length: {len(resp.content)}")
|
||
|
|
except Exception as e:
|
||
|
|
print(f"Error with default settings: {e}")
|
||
|
|
|
||
|
|
print("\nTesting with http2=True...")
|
||
|
|
try:
|
||
|
|
with httpx.Client(verify=True, headers=headers, timeout=30.0, http2=True) as client:
|
||
|
|
resp = client.get(url)
|
||
|
|
print(f"Status: {resp.status_code}")
|
||
|
|
except Exception as e:
|
||
|
|
print(f"Error with http2=True: {e}")
|
||
|
|
|
||
|
|
print("\nTesting with verify=False...")
|
||
|
|
try:
|
||
|
|
with httpx.Client(verify=False, headers=headers, timeout=30.0) as client:
|
||
|
|
resp = client.get(url)
|
||
|
|
print(f"Status: {resp.status_code}")
|
||
|
|
except Exception as e:
|
||
|
|
print(f"Error with verify=False: {e}")
|
||
|
|
|
||
|
|
import requests
|
||
|
|
print("\nTesting with requests (HTTP/1.1)...")
|
||
|
|
try:
|
||
|
|
resp = requests.get(url, headers=headers, timeout=30.0)
|
||
|
|
print(f"Status: {resp.status_code}")
|
||
|
|
except Exception as e:
|
||
|
|
print(f"Error with requests: {e}")
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
test_libgen_ssl()
|