исправил недачеты
This commit is contained in:
13
main.py
13
main.py
@@ -6,6 +6,7 @@ import subprocess
|
|||||||
import time
|
import time
|
||||||
from datetime import datetime as dt
|
from datetime import datetime as dt
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import random
|
||||||
|
|
||||||
# Сторонние библиотеки (third-party)
|
# Сторонние библиотеки (third-party)
|
||||||
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
||||||
@@ -86,15 +87,15 @@ def fetch_with_proxy(url, proxy, verify, timeout):
|
|||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
# Проверяем содержимое - если это ошибка от прокси
|
# Проверяем содержимое - если это ошибка от прокси
|
||||||
if '"message":"Request failed' in response.text or '403' in response.text[:500]:
|
if '"message":"Request failed' in response.text or '403' in response.text[:500]:
|
||||||
# print(f"Proxy {proxy} - Site returned 403 (inside response)")
|
print(f"Proxy {proxy} - Site returned 403 (inside response)")
|
||||||
return None
|
return None
|
||||||
# print(f"Proxy {proxy} - SUCCESS")
|
print(f"Proxy {proxy} - SUCCESS")
|
||||||
return response.text
|
return response.text
|
||||||
elif response.status_code == 403:
|
elif response.status_code == 403:
|
||||||
# print(f"Proxy {proxy} - 403 Forbidden")
|
print(f"Proxy {proxy} - 403 Forbidden")
|
||||||
return None # Прокси работает, но сайт блокирует
|
return None # Прокси работает, но сайт блокирует
|
||||||
else:
|
else:
|
||||||
# print(f"Proxy {proxy} - Status {response.status_code}")
|
print(f"Proxy {proxy} - Status {response.status_code}")
|
||||||
return None
|
return None
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
@@ -442,5 +443,5 @@ async def download_file(path: str, title: str):
|
|||||||
path = f"./{path}/{title}.docx" #os.path.abspath(path)
|
path = f"./{path}/{title}.docx" #os.path.abspath(path)
|
||||||
return FileResponse(path=path, filename=f'{title}.docx', media_type='multipart/form-data')
|
return FileResponse(path=path, filename=f'{title}.docx', media_type='multipart/form-data')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
# if __name__ == "__main__":
|
||||||
uvicorn.run("main:app", port=8001, reload=True)
|
# uvicorn.run("main:app", port=8001, reload=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user