get-pwbrowser-sync

Instantiate a playwright chromium (sync as opposed to async) browser


Install
pip install get-pwbrowser-sync==0.1.3

Documentation

get-pwbrowser-sync

[tests]pythonCode style: blackLicense: MITPyPI version

Instantiate a playwright firefox sync (as opposed to async) browser

Installation

pip install get-pwbrowser-sync

# or
# pip install git+https://github.com/ffreemt/get-pwbrowser-sync.git
# python -m playwright install chromium
or via poetry poetry add git+https://github.com/ffreemt/get-pwbrowser-sync.git && python -m playwright install chromium

Usage

from get_pwbrowser_sync import get_pwbrowser_sync

browser = get_pwbrowser_sync()
page = browser.new_page()
page.goto("http://www.baidu.com")
print(page.title())
# '百度一下,你就知道'

Use of .env and os.environ

The browser can be run in a headful manner (to actually see what's going on):

from get_pwbrowser_sync import get_pwbrowser_sync
browser = get_pwbrowser_sync(headless=False)

Some related parameters HEADFUL, DEBUG and PROXY can be set in shell environ or in .env with prefix PWBROWSER_.

e.g., set PWBROWSER_HEADFUL=1 in Windows or export PWBROWSER_HEADFUL=1 in Linux and freinds)

or in .env

# .env
PWBROWSER_HEADFUL=1

For more details have a look at the source code.