API Reference

Launcher

pyppeteer.launcher.launch(options=None, **kwargs)[source]

Start chromium process and return Browser object.

Return type:Browser
pyppeteer.launcher.connect(options=None)[source]

Not Implemented.

Return type:Browser

Browser

class pyppeteer.browser.Browser(connection: pyppeteer.connection.Connection, ignoreHTTPSErrors: bool, closeCallback: typing.Callable[NoneType]) → None[source]

Bases: object

Browser class.

Make new browser object.

coroutine newPage(self)[source]

Make new page on browser and return it.

Return type:Page
close()[source]

Close connections and terminate browser process.

Return type:None

Page

class pyppeteer.page.Page(client, ignoreHTTPSErrors=True, screenshotTaskQueue=None)[source]

Bases: pyee.EventEmitter

Page class.

Make new page object.

coroutine J(self, selector)

Get Element which matches selector.

Return type:Optional[ElementHandle]
coroutine JJ(self, selector)

Get Element which matches selector.

Return type:List[ElementHandle]
coroutine Jeval(self, selector, pageFunction, *args)

Execute function on element which matches selector.

Return type:Optional[Any]
coroutine addScriptTag(self, url)[source]

Add script tag to this page.

coroutine click(self, selector, options=None, **kwargs)[source]

Click element which matches selector.

Return type:None
coroutine close(self)[source]

Close connection.

Return type:None
coroutine content(self)[source]

Get the whole HTML contents of the page.

Return type:str
coroutine cookies(self, *urls)[source]

Get cookies.

Return type:dict
coroutine deleteCookie(self, *cookies)[source]

Delete cookie.

Return type:None
coroutine emulate(self, options=None, **kwargs)[source]

Emulate viewport and user agent.

Return type:None
coroutine emulateMedia(self, mediaType=None)[source]

Emulate css media type of the page.

Return type:None
coroutine evaluate(self, pageFunction, *args)[source]

Execute js-function on this page and get result.

Return type:str
coroutine evaluateOnNewDocument(self, pageFunction, *args)[source]

Evaluate js-function on new document.

Return type:None
coroutine exposeFunction(self, name, puppeteerFunction)[source]

Execute function on this page.

Return type:None
coroutine focus(self, selector)[source]

Focus the element which matches selector.

Return type:None
frames

Get frames.

Return type:List[Frame]
coroutine goBack(self, options=None, **kwargs)[source]

Go back history.

Return type:Optional[Response]
coroutine goForward(self, options=None, **kwargs)[source]

Go forward history.

Return type:Optional[Response]
coroutine goto(self, url, options=None, **kwargs)[source]

Got to url.

Return type:Optional[Response]
coroutine hover(self, selector)[source]

Mouse hover the element which matches selector.

Return type:None
coroutine injectFile(self, filePath)[source]

Inject file to this page.

keyboard

Get keybord object.

Return type:Keyboard
mainFrame

Get main frame.

Return type:Optional[Frame]
mouse

Get mouse object.

Return type:Mouse
coroutine pdf(self, options=None, **kwargs)[source]

Not yet implemented.

Return type:bytes
coroutine plainText(self)[source]

Get page content as plain text.

Return type:str
coroutine press(self, key, options=None, **kwargs)[source]

Press key.

Return type:None
coroutine querySelector(self, selector)[source]

Get Element which matches selector.

Return type:Optional[ElementHandle]
coroutine querySelectorAll(self, selector)[source]

Get Element which matches selector.

Return type:List[ElementHandle]
coroutine querySelectorEval(self, selector, pageFunction, *args)[source]

Execute function on element which matches selector.

Return type:Optional[Any]
coroutine reload(self, options=None, **kwargs)[source]

Reload this page.

Return type:Optional[Response]
coroutine screenshot(self, options=None, **kwargs)[source]

Take screen shot.

Return type:bytes
coroutine setContent(self, html)[source]

Set content.

Return type:None
coroutine setCookie(self, *cookies)[source]

Set cookies.

Return type:None
coroutine setExtraHTTPHeaders(self, headers)[source]

Set extra http headers.

coroutine setJavaScriptEnabled(self, enabled)[source]

Set JavaScript enabled/disabled.

Return type:None
coroutine setRequestInterceptionEnabled(self, value)[source]

Enable request interception.

Return type:None
coroutine setUserAgent(self, userAgent)[source]

Set user agent.

coroutine setViewport(self, viewport)[source]

Set viewport.

Return type:None
coroutine tap(self, selector)[source]

Tap the element which matches selector.

coroutine title(self)[source]

Get page title.

Return type:str
touchscreen

Get touchscreen object.

Return type:Touchscreen
tracing

Get tracing object.

Return type:Tracing
coroutine type(self, text, options=None, **kwargs)[source]

Type text on the page.

Return type:None
url

Get url of this page.

Return type:str
viewport

Get viewport.

Return type:dict
waitFor(selectorOrFunctionOrTimeout, options=None, **kwargs)[source]

Wait for function, timeout, or element which matches on page.

Return type:Awaitable[+T_co]
waitForFunction(pageFunction, options=None, *args, **kwargs)[source]

Wait for function.

Return type:Awaitable[+T_co]
coroutine waitForNavigation(self, options=None, **kwargs)[source]

Wait navigation completes.

Return type:Optional[Response]
waitForSelector(selector, options=None, **kwargs)[source]

Wait until element which matches selector appears on page.

Return type:Awaitable[+T_co]

Keyboard

class pyppeteer.input.Keyboard(client: pyppeteer.connection.Session) → None[source]

Bases: object

Keyboard class.

Make new keyboard object.

coroutine down(self, key, options=None, **kwargs)[source]

Press down key.

Return type:None
coroutine sendCharacter(self, char)[source]

Send character.

Return type:None
coroutine up(self, key)[source]

Up pressed key.

Return type:None

Mouse

class pyppeteer.input.Mouse(client: pyppeteer.connection.Session, keyboard: pyppeteer.input.Keyboard) → None[source]

Bases: object

Mouse class.

Make new mouse object.

coroutine click(self, x, y, options=None, **kwargs)[source]

Click button at (x, y).

Return type:None
coroutine down(self, options=None, **kwargs)[source]

Press down button.

Return type:None
coroutine move(self, x, y, options=None, **kwargs)[source]

Move cursor.

Return type:None
coroutine up(self, options=None, **kwargs)[source]

Up pressed button.

Return type:None

Tracing

class pyppeteer.tracing.Tracing(client: pyppeteer.connection.Session) → None[source]

Bases: object

Tracing class.

Make new tracing object.

coroutine start(self, options=None, **kwargs)[source]

Start.

Return type:None
coroutine stop(self)[source]

Stop.

Return type:Awaitable[+T_co]

Dialog

class pyppeteer.dialog.Dialog(client: pyppeteer.connection.Session, type: str, message: str, defaultValue: str = ‘’) → None[source]

Bases: object

Dialog class.

Make new dialog.

coroutine accept(self, promptText=’‘)[source]

Accept the dialog.

Return type:None
defaultValue()[source]

Get default selected dialog value.

Return type:str
coroutine dismiss(self)[source]

Dismiss the dialog.

Return type:None
message()[source]

Get dialog message.

Return type:str
type

Get dialog type.

Return type:str

Frame

class pyppeteer.frame_manager.Frame(client: pyppeteer.connection.Session, mouse: pyppeteer.input.Mouse, touchscreen: pyppeteer.input.Touchscreen, parentFrame: typing.Union[_ForwardRef(‘Frame’), NoneType], frameId: str) → None[source]

Bases: object

Frame class.

Make new frame.

coroutine J(self, selector)

Get element which matches selector string.

If selector matches multiple elements, return first-matched element.

Return type:Optional[ElementHandle]
coroutine JJ(self, selector)

Get all elelments which matches selector.

Return type:List[ElementHandle]
coroutine Jeval(self, selector, pageFunction, *args)

Execute function on element which matches selector.

Return type:Optional[Any]
coroutine addScriptTag(self, url)[source]

Add script tag to this frame.

Return type:str
childFrames

Get child frames.

Return type:List[Frame]
coroutine evaluate(self, pageFunction, *args)[source]

Evaluate pageFunction on this frame.

Return type:str
coroutine injectFile(self, filePath)[source]

Inject file to the frame.

Return type:str
isDetached

Check if this frame is detached.

Return type:bool
name

Get frame name.

Return type:str
parentFrame

Get parent frame.

Return type:Optional[Frame]
coroutine querySelector(self, selector)[source]

Get element which matches selector string.

If selector matches multiple elements, return first-matched element.

Return type:Optional[ElementHandle]
coroutine querySelectorAll(self, selector)[source]

Get all elelments which matches selector.

Return type:List[ElementHandle]
coroutine querySelectorEval(self, selector, pageFunction, *args)[source]

Execute function on element which matches selector.

Return type:Optional[Any]
coroutine title(self)[source]

Get title of the frame.

Return type:str
url

Get url.

Return type:str
waitFor(selectorOrFunctionOrTimeout, options=None, **kwargs)[source]

Wait until selectorOrFunctionOrTimeout.

Return type:Awaitable[+T_co]
waitForFunction(pageFunction, options=None, *args, **kwargs)[source]

Wait for js function return true.

Return type:Awaitable[+T_co]
waitForSelector(selector, options=None, **kwargs)[source]

Wait for selector matches element.

Return type:Awaitable[+T_co]

ElementHandle

class pyppeteer.element_handle.ElementHandle(client: pyppeteer.connection.Session, remoteObject: dict, mouse: pyppeteer.input.Mouse, touchscreen: pyppeteer.input.Touchscreen) → None[source]

Bases: object

ElementHandle class.

Make new element handle object.

coroutine attribute(self, key)[source]

[Deprecated] Get attribute value of the key of this element.

Return type:str
coroutine click(self, options=None, **kwargs)[source]

Click this element.

Return type:None
coroutine dispose(self)[source]

Release element handle.

Return type:None
coroutine evaluate(self, pageFunction, *args)[source]

Evaluate the pageFunction on browser.

Return type:Any
coroutine hover(self)[source]

Move mouse over this element.

Return type:None
coroutine tap(self)[source]

Tap this element.

Return type:None
coroutine uploadFile(self, *filePaths)[source]

Upload files.

Return type:dict

Request

class pyppeteer.network_manager.Request(client, requestId, interceptionId, url, resourceType, payload)[source]

Bases: object

Request class.

Make new request class.

coroutine abort(self)[source]

Abort request.

Return type:None
coroutine continue_(self, overrides)[source]

Continue request.

Return type:None
response

Get response.

Return type:Any

Response

class pyppeteer.network_manager.Response(client, request, status, headers)[source]

Bases: object

Response class.

Make new response.

buffer()[source]

Get buffer.

Return type:Awaitable[+T_co]
coroutine json(self)[source]

Get content as json.

Return type:dict
request

Get request.

Return type:Request
coroutine text(self)[source]

Get content as text.

Return type:str

.