fix: Added headers to requests

pull/8/head
db0 2023-06-24 13:38:26 +02:00
parent a18fe64a68
commit b1122ac048
1 changed files with 12 additions and 2 deletions

View File

@ -30,8 +30,18 @@ def get_admin_for_software(software: str, domain: str):
def get_nodeinfo(domain):
try:
wellknown = requests.get(f"https://{domain}/.well-known/nodeinfo", timeout=2).json()
nodeinfo = requests.get(wellknown['links'][0]['href'], timeout=2).json()
headers = {
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "none",
"Sec-Fetch-User": "?1",
"Sec-GPC": "1",
"User-Agent": "Fediseer/0.5",
}
wellknown = requests.get(f"https://{domain}/.well-known/nodeinfo", headers=headers, timeout=4).json()
headers["Sec-Fetch-Site"] = "cross-site"
nodeinfo = requests.get(wellknown['links'][0]['href'], headers=headers, timeout=2).json()
return nodeinfo
except Exception as err:
logger.debug(err)
return None