mirror of
https://github.com/ThePhaseless/Byparr.git
synced 2025-03-15 17:50:21 +08:00
add cache, pip, progress and fix bypass
This commit is contained in:
parent
73b3967618
commit
369faea1c3
9
.github/workflows/docker-publish.yml
vendored
9
.github/workflows/docker-publish.yml
vendored
@ -30,6 +30,7 @@ jobs:
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
cache: "pip"
|
||||
|
||||
- name: Set up Poetry
|
||||
run: pip install poetry
|
||||
@ -55,7 +56,13 @@ jobs:
|
||||
rm ./google-chrome-stable_current_amd64.deb
|
||||
|
||||
- name: Run tests
|
||||
run: poetry run pytest --retries 3 --retry-delay 5
|
||||
run: poetry run pytest --retries 2 --show-progress
|
||||
|
||||
- name: Upload screenshots if tests fail
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
path: screenshots
|
||||
|
||||
build:
|
||||
needs: test
|
||||
|
4
main.py
4
main.py
@ -60,17 +60,17 @@ def read_item(request: LinkRequest):
|
||||
source_bs = BeautifulSoup(source, "html.parser")
|
||||
title_tag = source_bs.title
|
||||
logger.info(f"Got webpage: {request.url}")
|
||||
if title_tag in src.utils.consts.CHALLENGE_TITLES:
|
||||
if title_tag and title_tag.string in src.utils.consts.CHALLENGE_TITLES:
|
||||
logger.info("Challenge detected")
|
||||
sb.uc_gui_click_captcha()
|
||||
logger.info("Clicked captcha")
|
||||
sb.save_screenshot("screenshot.png")
|
||||
|
||||
source = sb.get_page_source()
|
||||
source_bs = BeautifulSoup(source, "html.parser")
|
||||
title_tag = source_bs.title
|
||||
|
||||
if title_tag and title_tag.string in src.utils.consts.CHALLENGE_TITLES:
|
||||
sb.save_screenshot(f"./screenshots/{request.url}.png")
|
||||
raise HTTPException(
|
||||
status_code=500, detail="Could not bypass challenge"
|
||||
)
|
||||
|
15
poetry.lock
generated
15
poetry.lock
generated
@ -1324,6 +1324,19 @@ files = [
|
||||
[package.dependencies]
|
||||
pytest = "*"
|
||||
|
||||
[[package]]
|
||||
name = "pytest-progress"
|
||||
version = "1.3.0"
|
||||
description = "pytest plugin for instant test progress status"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
files = [
|
||||
{file = "pytest_progress-1.3.0.tar.gz", hash = "sha256:b2a6cd0b0cd8b50b19f56777402835e546dc8404eb7fa77ac2ace9dc719ec50e"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
pytest = ">=2.7"
|
||||
|
||||
[[package]]
|
||||
name = "pytest-rerunfailures"
|
||||
version = "14.0"
|
||||
@ -2182,4 +2195,4 @@ h11 = ">=0.9.0,<1"
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.12"
|
||||
content-hash = "15aa6bc34351d1ba1a293b12f8979d58d1d1b6d2716eec78b3de581dd59f53d4"
|
||||
content-hash = "b14c2514cac9868f24705f98bfe5aaae06ed4b21508b9e4622ada2938338b525"
|
||||
|
@ -18,6 +18,7 @@ seleniumbase = "^4.32.12"
|
||||
pyautogui = "^0.9.54"
|
||||
beautifulsoup4 = "^4.12.3"
|
||||
pytest-retry = "^1.6.3"
|
||||
pytest-progress = "^1.3.0"
|
||||
|
||||
|
||||
[build-system]
|
||||
|
Loading…
x
Reference in New Issue
Block a user