1
- # Pyppeteer Ghost Cursor
2
- Python port of <a href =" https://github.com/Xetera/ghost-cursor " >Xetera/ghost-cursor</a >, for use with pyppeteer .
1
+ # Python Ghost Cursor
2
+ Python port of <a href =" https://github.com/Xetera/ghost-cursor " >Xetera/ghost-cursor</a >, for use with Pyppeteer and Playwright .
3
3
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
5
5
like the definitely-not-robot you are.
6
6
7
7
## Installation
8
- ` pip install pyppeteer_ghost_cursor `
8
+ ` pip install python_ghost_cursor `
9
9
10
10
## Usage
11
11
12
12
Generating movement data between 2 coordinates.
13
13
14
14
``` python
15
- from pyppeteer_ghost_cursor import path
15
+ from python_ghost_cursor import path
16
16
17
17
start = {
18
18
" x" : 220 ,
@@ -36,11 +36,12 @@ route = path(start, end)
36
36
# ]
37
37
```
38
38
39
- Usage with pyppeteer :
39
+ Usage with Pyppeteer :
40
40
41
41
``` python
42
- from pyppeteer_ghost_cursor import createCursor
42
+ import asyncio
43
43
import pyppeteer
44
+ from python_ghost_cursor.pyppeteer import create_cursor
44
45
45
46
async def main (url ):
46
47
selector = " #sign-up button"
@@ -51,8 +52,50 @@ async def main(url):
51
52
await page.waitForSelector(selector)
52
53
await cursor.click(selector)
53
54
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 python_ghost_cursor.playwright_async 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
+
54
78
```
55
79
80
+ Usage with Playwright (sync):
81
+
82
+ ``` python
83
+ from playwright.sync_api import sync_playwright
84
+ from python_ghost_cursor.playwright_sync 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
+ ```
56
99
## More info
57
100
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 >
58
101
0 commit comments