-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
34 lines (26 loc) · 1 KB
/
test.py
File metadata and controls
34 lines (26 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from playwright.sync_api import sync_playwright, Playwright
from playwright_stealth import stealth_sync, StealthConfig
path_to_extension = "./"
user_data_dir = "/tmp/test-user-data-dir"
proxy = {"server": "45.67.2.115:5689"}
def run(playwright: Playwright):
context = playwright.chromium.launch_persistent_context(
user_data_dir,
headless=False,
args=[
f"--disable-extensions-except={path_to_extension}",
f"--load-extension={path_to_extension}",
"--disable-dev-shm-usage",
"--disable-blink-features=AutomationControlled"
],
proxy=proxy
)
config = StealthConfig(navigator_languages=False, navigator_vendor=False, navigator_user_agent=False)
page = context.new_page()
page.goto("https://www.sadcaptcha.com")
stealth_sync(page, config)
input("trigger the captcha")
# Test the background page as you would any other page.
context.close()
with sync_playwright() as playwright:
run(playwright)