mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 12:05:35 +00:00
Fix domain headers
This commit is contained in:
parent
0ab1ab8798
commit
8e3404979a
@ -49,7 +49,16 @@ def get_final_redirect_url(initial_url, max_timeout):
|
|||||||
|
|
||||||
# Create a client with redirects enabled
|
# Create a client with redirects enabled
|
||||||
try:
|
try:
|
||||||
with httpx.Client(follow_redirects=True, timeout=max_timeout, headers={'user-agent': get_headers()}) as client:
|
with httpx.Client(
|
||||||
|
follow_redirects=True,
|
||||||
|
timeout=max_timeout,
|
||||||
|
headers={
|
||||||
|
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
|
||||||
|
'accept-language': 'it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7',
|
||||||
|
'User-Agent': get_headers()
|
||||||
|
}
|
||||||
|
) as client:
|
||||||
|
|
||||||
response = client.get(initial_url)
|
response = client.get(initial_url)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
@ -59,7 +68,7 @@ def get_final_redirect_url(initial_url, max_timeout):
|
|||||||
return final_url
|
return final_url
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
console.print(f"[cyan]Test url[white]: [red]{initial_url}, [cyan]error[white]: [red]{e}")
|
console.print(f"\n[cyan]Test url[white]: [red]{initial_url}, [cyan]error[white]: [red]{e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def search_domain(site_name: str, base_url: str):
|
def search_domain(site_name: str, base_url: str):
|
||||||
@ -89,6 +98,7 @@ def search_domain(site_name: str, base_url: str):
|
|||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
timeout=max_timeout
|
timeout=max_timeout
|
||||||
) as client:
|
) as client:
|
||||||
|
|
||||||
response_follow = client.get(f"{base_url}.{domain}")
|
response_follow = client.get(f"{base_url}.{domain}")
|
||||||
response_follow.raise_for_status()
|
response_follow.raise_for_status()
|
||||||
|
|
||||||
@ -115,7 +125,6 @@ def search_domain(site_name: str, base_url: str):
|
|||||||
final_url = get_final_redirect_url(first_url, max_timeout)
|
final_url = get_final_redirect_url(first_url, max_timeout)
|
||||||
|
|
||||||
if final_url is not None:
|
if final_url is not None:
|
||||||
#console.print(f"\n[cyan]New final URL[white]: [green]{final_url}")
|
|
||||||
|
|
||||||
def extract_domain(url):
|
def extract_domain(url):
|
||||||
parsed_url = urlparse(url)
|
parsed_url = urlparse(url)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user