GithubHelp home page GithubHelp logo

gaopengfei-star / undetected-playwright-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kaliiiiiiiiii/undetected-playwright-python

0.0 0.0 0.0 5.17 MB

Undetected Python version of the Playwright testing and automation library.

Home Page: https://playwright.dev/python/

License: Apache License 2.0

Shell 0.15% JavaScript 0.12% Python 99.10% CSS 0.01% HTML 0.62%

undetected-playwright-python's Introduction

๐ŸŽญ Playwright for Python

PyPI version

This is a patch of the original playwright implementation for Python.

It currently passes for sure (tested on Win10):

  • โœ… [CloudFare]
  • โœ… [Bet365] (shape//F5 I think)
  • [Others] Unknown/Not tested

Warnings:

  • the Only chromium part for Playwright is patched.

Demos (tested on Win 10)

img.png img.png

Dependencies

  • Google-Chrome installed (channel="chrome" recommended, default)

Installation

From PyPi (recommended)

execute in your shell console

pip install undetected-playwright-patch

Installation note for UNIX//Linux

Resolve "Permission Denied" error (click to expand)

On UNIX-based OS, you might run into the following errors

Permission denied: '...python3.**/site-packages/undetected_playwright/driver/playwright.sh'

and

...python3.**/site-packages/undetected_playwright/driver/node: Permission denied

To resolve them, simply run

chmod +x <The path your terminal tells you>.sh
# so smth like: ...python3.**/site-packages/undetected_playwright/driver/playwright.sh

and

chmod +x <The path your terminal tells you for node>
# so smth like: ...python3.**/site-packages/undetected_playwright/driver/node

Build from this repo:

git clone https://github.com/kaliiiiiiiiii/undetected-playwright-python
cd undetected-playwright-python
python -m pip install -r local-requirements.txt
python build_patched.py

Example

import asyncio

# undetected-playwright here!
from undetected_playwright.async_api import async_playwright, Playwright


async def run(playwright: Playwright):
    args = []
    
    # disable navigator.webdriver:true flag
    args.append("--disable-blink-features=AutomationControlled")
    browser = await playwright.chromium.launch(headless=False,
                                               args=args)
    page = await browser.new_page()
    await page.goto("https://nowsecure.nl/#relax")
    input("Press ENTER to continue to Creep-JS:")
    await page.goto("https://nowsecure.nl/#relax")
    await page.goto("https://abrahamjuliot.github.io/creepjs/")
    input("Press ENTER to exit:")
    await browser.close()


async def main():
    async with async_playwright() as playwright:
        await run(playwright)


if __name__ == "__main__":
    loop = asyncio.ProactorEventLoop()
    loop.run_until_complete(main())
    # asyncio.run(main) # should work for non-Windows as well
# undetected-playwright here!
from undetected_playwright.sync_api import sync_playwright


with sync_playwright() as p:
    args = []
    
    # disable navigator.webdriver:true flag
    args.append("--disable-blink-features=AutomationControlled")
    browser = p.chromium.launch(args=args, headless=False)
    page = browser.new_page()
    page.goto("https://nowsecure.nl/#relax")
    input("Press ENTER to continue to Creep-JS:")
    page.goto("https://nowsecure.nl/#relax")
    page.goto("https://abrahamjuliot.github.io/creepjs/")
    input("Press ENTER to exit:")
    browser.close()

Documentation

See the original https://playwright.dev/python/docs/intro

API Reference

https://playwright.dev/python/docs/api/class-playwright

Patches

  • Runtime.enable
    • remove Runtime.enable occurences
    • patch _context(world) getter
      • isolatedWorld (utility)
      • main world (main)
      • reset on frame-reload//navigation

TODO's

  • add GitHub runner to build releases automated

undetected-playwright-python's People

Contributors

abr-storm avatar adamchainz avatar alberlc avatar arjunattam avatar artyl avatar aslushnikov avatar avodovnik avatar axelande avatar bo5o avatar bskdany avatar dependabot[bot] avatar dgozman avatar itslewin avatar jcheng5 avatar kaliiiiiiiiii avatar kianmeng avatar kumaraditya303 avatar m9810223 avatar marketionist avatar mattwmaster58 avatar mickmcc avatar microsoftopensource avatar mxschmitt avatar pavelfeldman avatar razerm avatar rwoll avatar sawt00th avatar tumregels avatar x0day avatar yury-s avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.