mirror of
https://forge.fsky.io/oneflux/omegafox.git
synced 2026-02-10 08:32:05 -08:00
README: Add Playwright usage example
This commit is contained in:
parent
c144539759
commit
fcacf8106d
1 changed files with 64 additions and 0 deletions
64
README.md
64
README.md
|
|
@ -350,6 +350,70 @@ Camoufox performs well against every major WAF I've tested. (Test sites from [Bo
|
||||||
|
|
||||||
Camoufox does **not** fully support injecting Chromium fingerprints. Some WAFs (such as [Interstitial](https://nopecha.com/demo/cloudflare)) test for Spidermonkey engine behavior, which is impossible to spoof.
|
Camoufox does **not** fully support injecting Chromium fingerprints. Some WAFs (such as [Interstitial](https://nopecha.com/demo/cloudflare)) test for Spidermonkey engine behavior, which is impossible to spoof.
|
||||||
|
|
||||||
|
## Playwright Usage
|
||||||
|
|
||||||
|
Camoufox is fully compatible with your existing Playwright code. You only have to change your browser initialization:
|
||||||
|
|
||||||
|
```py
|
||||||
|
browser = pw.firefox.launch(
|
||||||
|
executable_path='/path/to/camoufox/launch', # Path to the Camoufox launcher
|
||||||
|
args=['--config', '/path/to/config.json'], # Pass in file path or JSON string
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>
|
||||||
|
See full example script...
|
||||||
|
</summary>
|
||||||
|
|
||||||
|
```py
|
||||||
|
import asyncio
|
||||||
|
import json
|
||||||
|
from playwright.async_api import async_playwright
|
||||||
|
|
||||||
|
# Example config
|
||||||
|
CONFIG = {
|
||||||
|
'window.outerHeight': 1056,
|
||||||
|
'window.outerWidth': 1920,
|
||||||
|
'window.innerHeight': 1008,
|
||||||
|
'window.innerWidth': 1920,
|
||||||
|
'window.history.length': 4,
|
||||||
|
'navigator.userAgent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0',
|
||||||
|
'navigator.appCodeName': 'Mozilla',
|
||||||
|
'navigator.appName': 'Netscape',
|
||||||
|
'navigator.appVersion': '5.0 (Windows)',
|
||||||
|
'navigator.oscpu': 'Windows NT 10.0; Win64; x64',
|
||||||
|
'navigator.language': 'en-US',
|
||||||
|
'navigator.languages': ['en-US'],
|
||||||
|
'navigator.platform': 'Win32',
|
||||||
|
'navigator.hardwareConcurrency': 12,
|
||||||
|
'navigator.product': 'Gecko',
|
||||||
|
'navigator.productSub': '20030107',
|
||||||
|
'navigator.maxTouchPoints': 10,
|
||||||
|
}
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
async with async_playwright() as p:
|
||||||
|
# Create a Firefox instance to the launcher
|
||||||
|
browser = await p.firefox.launch(
|
||||||
|
# Pass in the Camoufox launcher and config JSON
|
||||||
|
executable_path='/path/to/camoufox/launch',
|
||||||
|
args=['--config', json.dumps(CONFIG)],
|
||||||
|
# Launch in headful mode
|
||||||
|
headless=False
|
||||||
|
)
|
||||||
|
# Continue as normal
|
||||||
|
page = await browser.new_page()
|
||||||
|
await page.goto('https://abrahamjuliot.github.io/creepjs/')
|
||||||
|
await asyncio.sleep(10)
|
||||||
|
await browser.close()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
asyncio.run(main())
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Build System
|
## Build System
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue