Add Referer header to search URL navigation
A direct hit to searchresults.en-gb.html with no Referer causes Cloudflare to hold the response body open (never sending HTML), so domcontentloaded never fires. Setting referer=HOMEPAGE makes the request look like the user searched from the homepage, which resolves the stall. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3c4bc633fe
commit
7b4bb72f15
1 changed files with 6 additions and 1 deletions
|
|
@ -592,7 +592,12 @@ class PlaywrightLocalBackend(ScraperBackend):
|
||||||
dest_id=dest_id, location_params=location_params)
|
dest_id=dest_id, location_params=location_params)
|
||||||
logger.info(f"Scraping page {page_num + 1}: {url}")
|
logger.info(f"Scraping page {page_num + 1}: {url}")
|
||||||
try:
|
try:
|
||||||
await page.goto(url, wait_until='domcontentloaded', timeout=90000)
|
# referer=HOMEPAGE makes the request look like the user
|
||||||
|
# searched from the homepage, which is required — a
|
||||||
|
# direct hit to searchresults with no Referer causes
|
||||||
|
# Cloudflare to hold the response body open indefinitely.
|
||||||
|
await page.goto(url, wait_until='domcontentloaded',
|
||||||
|
timeout=90000, referer=self.HOMEPAGE)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Page load timeout, continuing: {e}")
|
logger.warning(f"Page load timeout, continuing: {e}")
|
||||||
page_loaded = False
|
page_loaded = False
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue