All Projects → miyakogi → Pyppeteer

miyakogi / Pyppeteer

Licence: other
Headless chrome/chromium automation library (unofficial port of puppeteer)

Programming Languages

python
139335 projects - #7 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to Pyppeteer

learn-browser-testing
Repository for my upcoming course & workshop
Stars: ✭ 105 (-96.98%)
Mutual labels:  browser-automation, puppeteer
browser-pool
A Node.js library to easily manage and rotate a pool of web browsers, using any of the popular browser automation libraries like Puppeteer, Playwright, or SecretAgent.
Stars: ✭ 71 (-97.96%)
Mutual labels:  browser-automation, puppeteer
throughout
🎪 End-to-end testing made simple (using Jest and Puppeteer)
Stars: ✭ 16 (-99.54%)
Mutual labels:  headless-chrome, puppeteer
Apify Js
Apify SDK — The scalable web scraping and crawling library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.
Stars: ✭ 3,154 (-9.37%)
Mutual labels:  puppeteer, headless-chrome
puppeteer-github
GitHub automation driven by headless chrome.
Stars: ✭ 15 (-99.57%)
Mutual labels:  headless-chrome, puppeteer
puppeteer-autoscroll-down
Handle infinite scroll on websites by puppeteer
Stars: ✭ 40 (-98.85%)
Mutual labels:  headless-chrome, puppeteer
nest-puppeteer
Puppeteer (Headless Chrome) provider for Nest.js
Stars: ✭ 68 (-98.05%)
Mutual labels:  headless-chrome, puppeteer
Viewfinder
📷 BrowserBox - Remote isolated browser API for security, automation visibility and interactivity. Run on our cloud, or bring your own. Full scope double reverse web proxy with multi-tab, mobile-ready browser UI frontend. Plus co-browsing, advanced adaptive streaming, secure document viewing and more! But only in the Pro version. Get BB today! Se…
Stars: ✭ 1,741 (-49.97%)
Mutual labels:  browser-automation, puppeteer
purescript-toppokki
A binding to puppeteer to drive headless Chrome.
Stars: ✭ 48 (-98.62%)
Mutual labels:  headless-chrome, puppeteer
puppeteer-email
Email automation driven by headless chrome.
Stars: ✭ 135 (-96.12%)
Mutual labels:  headless-chrome, puppeteer
after-work.js
[DEPRECATED] CLI for automated tests in web projects.
Stars: ✭ 56 (-98.39%)
Mutual labels:  headless-chrome, puppeteer
hc-pdf-server
Convert HTML to PDF Server by headless chrome with TypeScript. The new version of hcep-pdf-server.
Stars: ✭ 24 (-99.31%)
Mutual labels:  headless-chrome, puppeteer
simplechrome
Webrecorders DevTools Protocol Automation Library
Stars: ✭ 16 (-99.54%)
Mutual labels:  browser-automation, puppeteer
browser-automation-api
Browser automation API for repetitive web-based tasks, with a friendly user interface. You can use it to scrape content or do many other things like capture a screenshot, generate pdf, extract content or execute custom Puppeteer, Playwright functions.
Stars: ✭ 24 (-99.31%)
Mutual labels:  browser-automation, puppeteer
codepen-puppeteer
Use Puppeteer to download pens from Codepen.io as single html pages
Stars: ✭ 22 (-99.37%)
Mutual labels:  headless-chrome, puppeteer
puppeteer-instagram
Instagram automation driven by headless chrome.
Stars: ✭ 87 (-97.5%)
Mutual labels:  headless-chrome, puppeteer
puppet-master
Puppeteer as a service hosted on Saasify.
Stars: ✭ 25 (-99.28%)
Mutual labels:  headless-chrome, puppeteer
apify-cli
Apify command-line interface helps you create, develop, build and run Apify actors, and manage the Apify cloud platform.
Stars: ✭ 37 (-98.94%)
Mutual labels:  headless-chrome, puppeteer
phantom-lord
Handy API for Headless Chromium
Stars: ✭ 24 (-99.31%)
Mutual labels:  headless-chrome, puppeteer
thal
译文:Puppeteer 与 Chrome Headless —— 从入门到爬虫
Stars: ✭ 651 (-81.29%)
Mutual labels:  headless-chrome, puppeteer

Pyppeteer

Pyppeteer has moved to pyppeteer/pyppeteer


PyPI PyPI version Documentation Travis status AppVeyor status codecov

Unofficial Python port of puppeteer JavaScript (headless) chrome/chromium browser automation library.

Installation

Pyppeteer requires python 3.6+. (experimentally supports python 3.5)

Install by pip from PyPI:

python3 -m pip install pyppeteer

Or install latest version from github:

python3 -m pip install -U git+https://github.com/miyakogi/pyppeteer.git@dev

Usage

Note: When you run pyppeteer first time, it downloads a recent version of Chromium (~100MB). If you don't prefer this behavior, run pyppeteer-install command before running scripts which uses pyppeteer.

Example: open web page and take a screenshot.

import asyncio
from pyppeteer import launch

async def main():
    browser = await launch()
    page = await browser.newPage()
    await page.goto('http://example.com')
    await page.screenshot({'path': 'example.png'})
    await browser.close()

asyncio.get_event_loop().run_until_complete(main())

Example: evaluate script on the page.

import asyncio
from pyppeteer import launch

async def main():
    browser = await launch()
    page = await browser.newPage()
    await page.goto('http://example.com')
    await page.screenshot({'path': 'example.png'})

    dimensions = await page.evaluate('''() => {
        return {
            width: document.documentElement.clientWidth,
            height: document.documentElement.clientHeight,
            deviceScaleFactor: window.devicePixelRatio,
        }
    }''')

    print(dimensions)
    # >>> {'width': 800, 'height': 600, 'deviceScaleFactor': 1}
    await browser.close()

asyncio.get_event_loop().run_until_complete(main())

Pyppeteer has almost same API as puppeteer. More APIs are listed in the document.

Puppeteer's document and troubleshooting are also useful for pyppeteer users.

Differences between puppeteer and pyppeteer

Pyppeteer is to be as similar as puppeteer, but some differences between python and JavaScript make it difficult.

These are differences between puppeteer and pyppeteer.

Keyword arguments for options

Puppeteer uses object (dictionary in python) for passing options to functions/methods. Pyppeteer accepts both dictionary and keyword arguments for options.

Dictionary style option (similar to puppeteer):

browser = await launch({'headless': True})

Keyword argument style option (more pythonic, isn't it?):

browser = await launch(headless=True)

Element selector method name ($ -> querySelector)

In python, $ is not usable for method name. So pyppeteer uses Page.querySelector()/Page.querySelectorAll()/Page.xpath() instead of Page.$()/Page.$$()/Page.$x(). Pyppeteer also has shorthands for these methods, Page.J(), Page.JJ(), and Page.Jx().

Arguments of Page.evaluate() and Page.querySelectorEval()

Puppeteer's version of evaluate() takes JavaScript raw function or string of JavaScript expression, but pyppeteer takes string of JavaScript. JavaScript strings can be function or expression. Pyppeteer tries to automatically detect the string is function or expression, but sometimes it fails. If expression string is treated as function and error is raised, add force_expr=True option, which force pyppeteer to treat the string as expression.

Example to get page content:

content = await page.evaluate('document.body.textContent', force_expr=True)

Example to get element's inner text:

element = await page.querySelector('h1')
title = await page.evaluate('(element) => element.textContent', element)

Future Plan

  1. Catch up development of puppeteer
    • Not intend to add original API which puppeteer does not have

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].