diff --git a/docker/server.py b/docker/server.py
index 274e55f..71066a7 100644
--- a/docker/server.py
+++ b/docker/server.py
@@ -79,6 +79,7 @@ class ChallengeResponse(BaseModel):
async def chromium(data: ChallengeRequest):
launch_data = {
"headless": False,
+ "devtools": True,
"proxy": {
"server": data.proxy.server,
"username": data.proxy.username,
diff --git a/example/test_chromium_cron_challenge.py b/example/test_chromium_cron_challenge.py
index f68c0b1..a0a0c0d 100644
--- a/example/test_chromium_cron_challenge.py
+++ b/example/test_chromium_cron_challenge.py
@@ -7,13 +7,14 @@
async def test_cf_challenge(url: str):
# not use cf_clearance, cf challenge is fail
- res = requests.get("https://nowsecure.nl")
+ res = requests.get(url)
assert "
Just a moment..." in res.text
# get cf_clearance
with Display():
async with async_playwright() as p:
browser = await p.chromium.launch(
headless=False,
+ devtools=True,
)
context = await browser.new_context()
page = await context.new_page()
@@ -38,7 +39,7 @@ async def test_cf_challenge(url: str):
# use cf_clearance, must be same IP and UA
headers = {"user-agent": ua}
cookies = {"cf_clearance": cf_clearance_value}
- res = requests.get("https://nowsecure.nl", headers=headers, cookies=cookies)
+ res = requests.get(url, headers=headers, cookies=cookies)
assert "Just a moment..." not in res.text
diff --git a/example/test_firefox_challenge.py b/example/test_firefox_challenge.py
index ac14d09..63a651e 100644
--- a/example/test_firefox_challenge.py
+++ b/example/test_firefox_challenge.py
@@ -10,9 +10,7 @@ async def test_cf_challenge(url: str):
assert "Just a moment..." in res.text
# get cf_clearance
async with async_playwright() as p:
- browser = await p.firefox.launch(
- headless=False,
- )
+ browser = await p.firefox.launch(headless=False)
context = await browser.new_context()
page = await context.new_page()
await page.goto(url)
@@ -30,7 +28,6 @@ async def test_cf_challenge(url: str):
raise
else:
print("No cloudflare challenges encountered")
-
await browser.close()
# use cf_clearance, must be same IP and UA
headers = {"user-agent": ua}
diff --git a/pdm.lock b/pdm.lock
index 6fdbaf5..6ea6c73 100644
--- a/pdm.lock
+++ b/pdm.lock
@@ -6,7 +6,7 @@ groups = ["default", "dev"]
cross_platform = true
static_urls = false
lock_version = "4.3"
-content_hash = "sha256:1d940f0d099361aec978c3ded08f7f798375e745e3d70236c08ed9140183652d"
+content_hash = "sha256:c5e4df599f33d97ef61c914961634920a14e501f1fd129f01f1b6a06e40f2b7c"
[[package]]
name = "anyio"
@@ -410,6 +410,17 @@ files = [
{file = "pyee-9.0.4.tar.gz", hash = "sha256:2770c4928abc721f46b705e6a72b0c59480c4a69c9a83ca0b00bb994f1ea4b32"},
]
+[[package]]
+name = "pysocks"
+version = "1.7.1"
+requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
+summary = "A Python SOCKS client module. See https://github.com/Anorov/PySocks for more information."
+files = [
+ {file = "PySocks-1.7.1-py27-none-any.whl", hash = "sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299"},
+ {file = "PySocks-1.7.1-py3-none-any.whl", hash = "sha256:2725bd0a9925919b9b51739eea5f9e2bae91e83288108a9ad338b2e3a4435ee5"},
+ {file = "PySocks-1.7.1.tar.gz", hash = "sha256:3f8804571ebe159c380ac6de37643bb4685970655d3bba243530d6558b799aa0"},
+]
+
[[package]]
name = "pyvirtualdisplay"
version = "3.0"
@@ -469,18 +480,33 @@ files = [
[[package]]
name = "requests"
-version = "2.29.0"
+version = "2.31.0"
requires_python = ">=3.7"
summary = "Python HTTP for Humans."
dependencies = [
"certifi>=2017.4.17",
"charset-normalizer<4,>=2",
"idna<4,>=2.5",
- "urllib3<1.27,>=1.21.1",
+ "urllib3<3,>=1.21.1",
+]
+files = [
+ {file = "requests-2.31.0-py3-none-any.whl", hash = "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f"},
+ {file = "requests-2.31.0.tar.gz", hash = "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"},
+]
+
+[[package]]
+name = "requests"
+version = "2.31.0"
+extras = ["socks"]
+requires_python = ">=3.7"
+summary = "Python HTTP for Humans."
+dependencies = [
+ "PySocks!=1.5.7,>=1.5.6",
+ "requests==2.31.0",
]
files = [
- {file = "requests-2.29.0-py3-none-any.whl", hash = "sha256:e8f3c9be120d3333921d213eef078af392fba3933ab7ed2d1cba3b56f2568c3b"},
- {file = "requests-2.29.0.tar.gz", hash = "sha256:f2e34a75f4749019bb0e3effb66683630e4ffeaf75819fb51bebef1bf5aef059"},
+ {file = "requests-2.31.0-py3-none-any.whl", hash = "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f"},
+ {file = "requests-2.31.0.tar.gz", hash = "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"},
]
[[package]]
diff --git a/pyproject.toml b/pyproject.toml
index efe8786..688b0cb 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -45,5 +45,5 @@ dev = [
"fastapi==0.99.1",
"uvicorn==0.23.0",
"pyvirtualdisplay==3.0",
- "requests==2.29.0",
+ "requests[socks]>=2.29.0",
]