Mythus commited on
Commit
0a0e59b
·
verified ·
1 Parent(s): 54f9540

Update run.py

Browse files
Files changed (1) hide show
  1. run.py +1 -18
run.py CHANGED
@@ -8,7 +8,6 @@ headers = {
8
  'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0',
9
  'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
10
  'Accept-Language': 'en-US,en;q=0.5',
11
- 'Accept-Encoding': 'gzip, deflate, br, zstd',
12
  'DNT': '1',
13
  'Sec-GPC': '1',
14
  'Connection': 'keep-alive',
@@ -25,26 +24,10 @@ headers = {
25
  # Send the request using httpx
26
  try:
27
  response = httpx.get(url, headers=headers, timeout=10)
28
- print(response.text)
29
 
30
  if response.status_code == 200:
31
- # Decompress if needed
32
- content = response.read()
33
- if response.headers.get('Content-Encoding') == 'gzip':
34
- import gzip
35
- content = gzip.decompress(content)
36
- elif response.headers.get('Content-Encoding') == 'br':
37
- import brotli
38
- content = brotli.decompress(content)
39
- elif response.headers.get('Content-Encoding') == 'deflate':
40
- import zlib
41
- content = zlib.decompress(content)
42
-
43
- # Decode bytes to string
44
- content = content.decode('utf-8')
45
-
46
  print("Page content fetched successfully.")
47
- print(content)
48
  else:
49
  print(f"Failed to fetch the page. Status code: {response.status_code}")
50
  except httpx.RequestError as exc:
 
8
  'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0',
9
  'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
10
  'Accept-Language': 'en-US,en;q=0.5',
 
11
  'DNT': '1',
12
  'Sec-GPC': '1',
13
  'Connection': 'keep-alive',
 
24
  # Send the request using httpx
25
  try:
26
  response = httpx.get(url, headers=headers, timeout=10)
 
27
 
28
  if response.status_code == 200:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  print("Page content fetched successfully.")
30
+ print(response.text)
31
  else:
32
  print(f"Failed to fetch the page. Status code: {response.status_code}")
33
  except httpx.RequestError as exc: