mirror of
https://github.com/ThePhaseless/Byparr.git
synced 2025-03-16 02:00: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
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "3.12"
|
python-version: "3.12"
|
||||||
|
cache: "pip"
|
||||||
|
|
||||||
- name: Set up Poetry
|
- name: Set up Poetry
|
||||||
run: pip install poetry
|
run: pip install poetry
|
||||||
@ -55,7 +56,13 @@ jobs:
|
|||||||
rm ./google-chrome-stable_current_amd64.deb
|
rm ./google-chrome-stable_current_amd64.deb
|
||||||
|
|
||||||
- name: Run tests
|
- 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:
|
build:
|
||||||
needs: test
|
needs: test
|
||||||
|
4
main.py
4
main.py
@ -60,17 +60,17 @@ def read_item(request: LinkRequest):
|
|||||||
source_bs = BeautifulSoup(source, "html.parser")
|
source_bs = BeautifulSoup(source, "html.parser")
|
||||||
title_tag = source_bs.title
|
title_tag = source_bs.title
|
||||||
logger.info(f"Got webpage: {request.url}")
|
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")
|
logger.info("Challenge detected")
|
||||||
sb.uc_gui_click_captcha()
|
sb.uc_gui_click_captcha()
|
||||||
logger.info("Clicked captcha")
|
logger.info("Clicked captcha")
|
||||||
sb.save_screenshot("screenshot.png")
|
|
||||||
|
|
||||||
source = sb.get_page_source()
|
source = sb.get_page_source()
|
||||||
source_bs = BeautifulSoup(source, "html.parser")
|
source_bs = BeautifulSoup(source, "html.parser")
|
||||||
title_tag = source_bs.title
|
title_tag = source_bs.title
|
||||||
|
|
||||||
if title_tag and title_tag.string in src.utils.consts.CHALLENGE_TITLES:
|
if title_tag and title_tag.string in src.utils.consts.CHALLENGE_TITLES:
|
||||||
|
sb.save_screenshot(f"./screenshots/{request.url}.png")
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=500, detail="Could not bypass challenge"
|
status_code=500, detail="Could not bypass challenge"
|
||||||
)
|
)
|
||||||
|
15
poetry.lock
generated
15
poetry.lock
generated
@ -1324,6 +1324,19 @@ files = [
|
|||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
pytest = "*"
|
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]]
|
[[package]]
|
||||||
name = "pytest-rerunfailures"
|
name = "pytest-rerunfailures"
|
||||||
version = "14.0"
|
version = "14.0"
|
||||||
@ -2182,4 +2195,4 @@ h11 = ">=0.9.0,<1"
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.12"
|
python-versions = "^3.12"
|
||||||
content-hash = "15aa6bc34351d1ba1a293b12f8979d58d1d1b6d2716eec78b3de581dd59f53d4"
|
content-hash = "b14c2514cac9868f24705f98bfe5aaae06ed4b21508b9e4622ada2938338b525"
|
||||||
|
@ -18,6 +18,7 @@ seleniumbase = "^4.32.12"
|
|||||||
pyautogui = "^0.9.54"
|
pyautogui = "^0.9.54"
|
||||||
beautifulsoup4 = "^4.12.3"
|
beautifulsoup4 = "^4.12.3"
|
||||||
pytest-retry = "^1.6.3"
|
pytest-retry = "^1.6.3"
|
||||||
|
pytest-progress = "^1.3.0"
|
||||||
|
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user