Spaces:
Sleeping
Sleeping
Commit
·
6db47e9
1
Parent(s):
a35a006
mimic real user
Browse files
main.py
CHANGED
@@ -22,8 +22,22 @@ async def scrape_visible_text(url):
|
|
22 |
async with async_playwright() as p:
|
23 |
browser = await p.chromium.launch(headless=True) # Launch browser in headless mode
|
24 |
context = await browser.new_context(
|
25 |
-
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/
|
26 |
-
viewport={"width": 1280, "height": 800}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
)
|
28 |
page = await context.new_page()
|
29 |
await page.goto(url, wait_until="networkidle")
|
|
|
22 |
async with async_playwright() as p:
|
23 |
browser = await p.chromium.launch(headless=True) # Launch browser in headless mode
|
24 |
context = await browser.new_context(
|
25 |
+
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
|
26 |
+
viewport={"width": 1280, "height": 800},
|
27 |
+
extra_http_headers={
|
28 |
+
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
29 |
+
"accept-encoding": "gzip, deflate, br, zstd",
|
30 |
+
"accept-language": "en-US,en;q=0.9,hi;q=0.8",
|
31 |
+
"cache-control": "max-age=0",
|
32 |
+
"sec-ch-ua": '"Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"',
|
33 |
+
"sec-ch-ua-mobile": "?0",
|
34 |
+
"sec-ch-ua-platform": '"Windows"',
|
35 |
+
"sec-fetch-dest": "document",
|
36 |
+
"sec-fetch-mode": "navigate",
|
37 |
+
"sec-fetch-site": "none",
|
38 |
+
"sec-fetch-user": "?1",
|
39 |
+
"upgrade-insecure-requests": "1"
|
40 |
+
}
|
41 |
)
|
42 |
page = await context.new_page()
|
43 |
await page.goto(url, wait_until="networkidle")
|