forkeado de spla/fediverse
Added user agent
This commit is contained in:
pare
c6ec648fe2
commit
7c75ca678c
S'han modificat 2 arxius amb 9 adicions i 3 eliminacions
|
@ -79,8 +79,10 @@ async def getsoft(server):
|
|||
|
||||
url = 'https://' + server
|
||||
|
||||
user_agent = {'User-agent': 'Mozilla/5.0'}
|
||||
|
||||
timeout = aiohttp.ClientTimeout(total=3)
|
||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||
async with aiohttp.ClientSession(timeout=timeout, headers=user_agent) as session:
|
||||
for api in apis:
|
||||
try:
|
||||
async with session.get(url + api) as response:
|
||||
|
|
|
@ -50,7 +50,9 @@ def get_peers(peer):
|
|||
|
||||
try:
|
||||
|
||||
response = requests.get('https://' + peer + peers_api, timeout=2)
|
||||
user_agent = {'User-agent': 'Mozilla/5.0'}
|
||||
|
||||
response = requests.get('https://' + peer + peers_api, headers = user_agent, timeout=3)
|
||||
|
||||
response_json = response.json()
|
||||
|
||||
|
@ -126,7 +128,9 @@ if __name__ == '__main__':
|
|||
|
||||
world_peers = []
|
||||
|
||||
res = requests.get('https://' + mastodon_hostname + peers_api)
|
||||
user_agent = {'User-agent': 'Mozilla/5.0'}
|
||||
|
||||
res = requests.get('https://' + mastodon_hostname + peers_api, headers = user_agent, timeout=3)
|
||||
|
||||
hostname_peers = res.json()
|
||||
|
||||
|
|
Loading…
Referencia en una nova incidència