how to filter network_requests when set capture_network_requests=True #1577
Unanswered
wangning182
asked this question in
Forums - Q&A
Replies: 1 comment
-
|
To reduce noise at the source, use browser_config = BrowserConfig(
text_mode=True, # disables images and rich content
avoid_ads=True, # blocks ad/tracker requests
avoid_css=True, # blocks CSS files
)To filter captured requests after the crawl: config = CrawlerRunConfig(capture_network_requests=True)
result = await crawler.arun(url, config=config)
all_requests = result.network_requests or []
# Filter by type
api_calls = [r for r in all_requests if r.get("event_type") == "response"
and "/api/" in r.get("url", "")]
xhr_only = [r for r in all_requests if r.get("resource_type") in ("xhr", "fetch")]
failed = [r for r in all_requests if r.get("event_type") == "requestfailed"]Available There's no built-in pre-filter on capture (like |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
page has a lot of requests, i wan't ge all of them
Beta Was this translation helpful? Give feedback.
All reactions