-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(project): ✨ add example project to get source page
- Loading branch information
1 parent
f651bee
commit e5e158e
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import asyncio | ||
import logging | ||
|
||
from cidipi.client import Browser | ||
from cidipi.protocols import commands | ||
|
||
logging.basicConfig( | ||
level=logging.DEBUG, format="[%(levelname)s] [%(name)s] %(message)s" | ||
) | ||
logging.getLogger("websockets.client").disabled = True | ||
|
||
|
||
async def main(): | ||
async with Browser(headless=True, remote_port=0) as browser: | ||
|
||
async def run(url: str): | ||
async with browser.new_tab() as tab: | ||
await tab.execute(commands.Page.enable()) | ||
await tab.execute(commands.DOM.enable()) | ||
await tab.execute(commands.Page.navigate(url=url)) | ||
await asyncio.sleep(3) | ||
result = await tab.execute( | ||
commands.Runtime.evaluate( | ||
expression="document.documentElement.outerHTML" | ||
) | ||
) | ||
logging.info(result) | ||
|
||
await run("https://www.google.com") | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |