Page.get_element#
- Page.get_element(element_id, do_copy=False)[source]#
Gets an element from its
idattribute. You can imagine this function asdocument.getElementByIdin JavaScript.Creating a page and getting an element by its
id:>>> page = Page(html_str='<html><h1 id="heading">Hello</h1></html>', url="/") >>> element = page.get_element(element_id="heading") >>> element <h1 id="heading">Hello</h1>
- Parameters:
element_id (str) –
do_copy (bool, default = False) – If
True, the element will be copied.
- Returns:
element – If the element was found, an Element object will be returned. Otherwise
Nonewill be returned.- Return type: