Purpose To make a cloudflare challenge pass successfully, Can be use cf_clearance bypassed by cloudflare, However, with the cf_clearance, make sure you use the same IP and UA as when you got it.
Project description
cf_clearance
Reference from playwright_stealth and undetected-chromedriver
Purpose To make a cloudflare challenge pass successfully, Can be use cf_clearance bypassed by cloudflare, However, with the cf_clearance, make sure you use the same IP and UA as when you got it.
Warning
Please use interface mode, You must add headless=False.
If you use it on linux or docker, use XVFB.
Install
$ pip install cf_clearance
Usage
sync
from playwright.sync_api import sync_playwright
from cf_clearance import sync_retry, stealth_sync
with sync_playwright() as p:
browser = p.chromium.launch(headless=False)
page = browser.new_page()
stealth_sync(page)
page.goto('https://nowsecure.nl')
res = sync_retry(page)
if res:
cppkies = page.context.cookies()
for cookie in cppkies:
if cookie.get('name') == 'cf_clearance':
print(cookie.get('value'))
ua = page.evaluate('() => {return navigator.userAgent}')
print(ua)
else:
print("fail")
browser.close()
async
import asyncio
from playwright.async_api import async_playwright
from cf_clearance import async_retry, stealth_async
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch(headless=False)
page = await browser.new_page()
await stealth_async(page)
await page.goto('https://nowsecure.nl')
res = await async_retry(page)
if res:
cppkies = await page.context.cookies()
for cookie in cppkies:
if cookie.get('name') == 'cf_clearance':
print(cookie.get('value'))
ua = await page.evaluate('() => {return navigator.userAgent}')
print(ua)
else:
print("fail")
await browser.close()
asyncio.get_event_loop().run_until_complete(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cf_clearance-0.0.2.tar.gz
(8.7 kB
view hashes)
Built Distribution
Close
Hashes for cf_clearance-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 742b7133e0644f15ac64f614cf051a71202ed48a7a147d98368208eda49d341f |
|
MD5 | dde07b04d894dce97d9bac4d6a0cfb02 |
|
BLAKE2b-256 | 6cdac4a7cecb9139cdb21cd243b3386f5240be168091420207e936b184387986 |