chg: Use cloudscraper to get around cloudflare blocks

This commit is contained in:
Sayantan Santra 2024-04-01 16:52:54 -05:00
parent 336b6470ca
commit 6cbe6454a3
Signed by: SinTan1729
GPG key ID: EB3E68BFBA25C85F
2 changed files with 4 additions and 6 deletions

View file

@ -11,8 +11,8 @@ requires-python = ">=3.6"
keywords = ["revanced", "patch"] keywords = ["revanced", "patch"]
license = { file = "LICENSE" } license = { file = "LICENSE" }
classifiers = ["Programming Language :: Python :: 3"] classifiers = ["Programming Language :: Python :: 3"]
dependencies = ["requests", "packaging", "bs4"] dependencies = ["cloudscraper", "packaging", "bs4"]
version = "1.1" version = "1.2"
[project.scripts] [project.scripts]
ReVancedBuilder = "ReVancedBuilder:ReVancedBuilder" ReVancedBuilder = "ReVancedBuilder:ReVancedBuilder"

View file

@ -8,7 +8,7 @@ import sys
import json import json
from packaging.version import Version from packaging.version import Version
import requests as req import cloudscraper as scraper
from bs4 import BeautifulSoup as bs from bs4 import BeautifulSoup as bs
from ReVancedBuilder.Cleanup import err_exit from ReVancedBuilder.Cleanup import err_exit
@ -99,9 +99,7 @@ def get_apks(appstate):
except req.exceptions.RequestException as e: except req.exceptions.RequestException as e:
err_exit(f"Error fetching patches, {e}", appstate) err_exit(f"Error fetching patches, {e}", appstate)
session = req.Session() session = scraper.create_scraper()
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'})
for app in build_config: for app in build_config:
# Check if we need to build an app # Check if we need to build an app