Skip to content

fix: derive default user agent from bundled Chromium - #2677

Open
Ha1baraA11 wants to merge 3 commits into
unclecode:developfrom
Ha1baraA11:pr/crawl4ai-2673
Open

Ha1baraA11 wants to merge 3 commits into
unclecode:developfrom
Ha1baraA11:pr/crawl4ai-2673

Conversation

@Ha1baraA11

Copy link
Copy Markdown
Contributor

Summary

Derive the default User-Agent's Chrome major from the Chromium version bundled by Playwright.
Related to #2673

List of files changed and why

  • crawl4ai/user_agent_generator.py: Read Chromium's browserVersion from Playwright's bundled browser manifest when building the default User-Agent, retaining a fallback for environments without Playwright.
  • tests/test_issue_2493_user_agent.py: Add regression coverage for the manifest-derived User-Agent and sec-ch-ua, and remove assumptions that the default major is fixed at 158.

How Has This Been Tested?

  • uv run --frozen --python=3.12 --with=pytest python -m pytest tests/test_issue_2493_user_agent.py::test_default_user_agent_uses_playwright_chromium_version -vv --disable-warnings — 1 passed.
  • python3 -m compileall -q crawl4ai tests — passed.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added/updated unit tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant