From 28b11257a47f4536e7ae8466a8a95a17a4d838ac Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Mon, 19 Dec 2022 19:18:08 +0000 Subject: [PATCH] Revert "Reuse cloudscraper" This reverts commit ea5f514adb0a0ae4a7e4be71324bd44459be6a59. --- pynyaata/connectors/core.py | 11 +++++++---- requirements.txt | 1 - 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pynyaata/connectors/core.py b/pynyaata/connectors/core.py index f81b3ab..4645e31 100644 --- a/pynyaata/connectors/core.py +++ b/pynyaata/connectors/core.py @@ -3,7 +3,7 @@ from enum import Enum from functools import wraps from json import dumps, loads -from cloudscraper import create_scraper +import requests from requests import RequestException from redis.exceptions import RedisError @@ -12,7 +12,7 @@ from ..config import CACHE_TIMEOUT, REQUESTS_TIMEOUT, logger, REDIS_ENABLED if REDIS_ENABLED: from ..config import cache -scraper = create_scraper() +cloudproxy_session = None class ConnectorReturn(Enum): @@ -80,16 +80,19 @@ def curl_content(url, params=None, ajax=False, debug=True, cloudflare=False): if ajax: headers['X-Requested-With'] = 'XMLHttpRequest' + if cloudflare: + headers['User-Agent'] = 'Googlebot/2.1 (+http://www.google.com/bot.html)' + try: if method == 'post': - response = scraper.post( + response = requests.post( url, params, timeout=REQUESTS_TIMEOUT, headers=headers ) else: - response = scraper.get( + response = requests.get( url, timeout=REQUESTS_TIMEOUT, headers=headers diff --git a/requirements.txt b/requirements.txt index 6d04bff..068a6af 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,4 +11,3 @@ python-dotenv==0.21.0 dateparser==1.1.4 redis==4.4.0 transmission-rpc==3.4.0 -cloudscraper==1.2.66