From 6cbe6454a3aa1c9a2463768a3cb80f1649b2b5c0 Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Mon, 1 Apr 2024 16:52:54 -0500 Subject: [PATCH] chg: Use cloudscraper to get around cloudflare blocks --- pyproject.toml | 4 ++-- src/ReVancedBuilder/APKPure_dl.py | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 32bb845..3ed5187 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,8 +11,8 @@ requires-python = ">=3.6" keywords = ["revanced", "patch"] license = { file = "LICENSE" } classifiers = ["Programming Language :: Python :: 3"] -dependencies = ["requests", "packaging", "bs4"] -version = "1.1" +dependencies = ["cloudscraper", "packaging", "bs4"] +version = "1.2" [project.scripts] ReVancedBuilder = "ReVancedBuilder:ReVancedBuilder" diff --git a/src/ReVancedBuilder/APKPure_dl.py b/src/ReVancedBuilder/APKPure_dl.py index 6d83e4d..852f4c9 100644 --- a/src/ReVancedBuilder/APKPure_dl.py +++ b/src/ReVancedBuilder/APKPure_dl.py @@ -8,7 +8,7 @@ import sys import json from packaging.version import Version -import requests as req +import cloudscraper as scraper from bs4 import BeautifulSoup as bs from ReVancedBuilder.Cleanup import err_exit @@ -99,9 +99,7 @@ def get_apks(appstate): except req.exceptions.RequestException as e: err_exit(f"Error fetching patches, {e}", appstate) - session = req.Session() - session.headers.update( - {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'}) + session = scraper.create_scraper() for app in build_config: # Check if we need to build an app