Azzan Dwi Riski
commited on
Commit
·
ac5d2c9
1
Parent(s):
5755686
fix issues
Browse files
app.py
CHANGED
@@ -167,17 +167,17 @@ def take_screenshot(url):
|
|
167 |
print(f"Taking screenshot with Playwright for URL: {url}")
|
168 |
with sync_playwright() as p:
|
169 |
browser = p.chromium.launch()
|
170 |
-
page = browser.new_page(
|
171 |
-
|
172 |
-
|
|
|
173 |
page.set_default_timeout(60000)
|
|
|
174 |
page.goto(url, wait_until="networkidle", timeout=60000)
|
175 |
page.wait_for_timeout(3000)
|
176 |
-
|
177 |
-
# Take viewport-only screenshot (default behavior)
|
178 |
-
page.screenshot(path=filepath) # full_page=False by default
|
179 |
browser.close()
|
180 |
-
|
181 |
print(f"Screenshot taken for URL: {url}")
|
182 |
return filepath
|
183 |
except Exception as e:
|
|
|
167 |
print(f"Taking screenshot with Playwright for URL: {url}")
|
168 |
with sync_playwright() as p:
|
169 |
browser = p.chromium.launch()
|
170 |
+
page = browser.new_page(
|
171 |
+
viewport={"width": 1280, "height": 800},
|
172 |
+
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
|
173 |
+
)
|
174 |
page.set_default_timeout(60000)
|
175 |
+
page.set_extra_http_headers({"Accept-Language": "en-US,en;q=0.9"})
|
176 |
page.goto(url, wait_until="networkidle", timeout=60000)
|
177 |
page.wait_for_timeout(3000)
|
178 |
+
page.screenshot(path=filepath)
|
|
|
|
|
179 |
browser.close()
|
180 |
+
|
181 |
print(f"Screenshot taken for URL: {url}")
|
182 |
return filepath
|
183 |
except Exception as e:
|