Skip to content

Commit 5b5aadf

Browse files
committed
update readme
1 parent b2bf575 commit 5b5aadf

File tree

1 file changed

+47
-4
lines changed

1 file changed

+47
-4
lines changed

README.md

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Pyppeteer Ghost Cursor
2-
Python port of <a href="https://github.com/Xetera/ghost-cursor">Xetera/ghost-cursor</a>, for use with pyppeteer.
2+
Python port of <a href="https://github.com/Xetera/ghost-cursor">Xetera/ghost-cursor</a>, for use with Pyppeteer and Playwright.
33

4-
> Generate realistic, human-like mouse movement data between coordinates or navigate between elements with puppeteer
4+
> Generate realistic, human-like mouse movement data between coordinates or navigate between elements with Pyppeteer/Playwright
55
like the definitely-not-robot you are.
66

77
## Installation
@@ -36,11 +36,12 @@ route = path(start, end)
3636
# ]
3737
```
3838

39-
Usage with pyppeteer:
39+
Usage with Pyppeteer:
4040

4141
```python
42-
from pyppeteer_ghost_cursor import createCursor
42+
import asyncio
4343
import pyppeteer
44+
from pyppeteer_ghost_cursor.pyppeteer import create_cursor
4445

4546
async def main(url):
4647
selector = "#sign-up button"
@@ -51,8 +52,50 @@ async def main(url):
5152
await page.waitForSelector(selector)
5253
await cursor.click(selector)
5354

55+
asyncio.run(main())
56+
57+
```
58+
59+
Usage with Playwright (async):
60+
61+
```python
62+
import asyncio
63+
from playwright.async_api import async_playwright
64+
from pyppeteer_ghost_cursor.playwright.async_api import create_cursor
65+
66+
async def main():
67+
async with async_playwright() as p:
68+
selector = "#sign-up button"
69+
browser = await p.chromium.launch(channel="chrome", headless=False)
70+
page = await browser.new_page()
71+
cursor = create_cursor(page)
72+
await page.goto(url)
73+
await page.wait_for_selector(selector)
74+
await cursor.click(selector)
75+
76+
asyncio.run(main())
77+
5478
```
5579

80+
Usage with Playwright (sync):
81+
82+
```python
83+
from playwright.sync_api import sync_playwright
84+
from pyppeteer_ghost_cursor.playwright.sync_api import create_cursor
85+
86+
def main():
87+
sync with sync_playwright() as p:
88+
selector = "#sign-up button"
89+
browser = p.chromium.launch(channel="chrome", headless=False)
90+
page = browser.new_page()
91+
cursor = create_cursor(page)
92+
page.goto(url)
93+
page.wait_for_selector(selector)
94+
cursor.click(selector)
95+
96+
main()
97+
98+
```
5699
## More info
57100
The original repo gives <a href="https://github.com/Xetera/ghost-cursor#puppeteer-specific-behavior"> a description of some of the cool features</a>, along with <a href="https://github.com/Xetera/ghost-cursor#how-does-it-work">a good explanation of how it works.</a>
58101

0 commit comments

Comments
 (0)