Skip to content

Commit a42f81b

Browse files
authored
Merge pull request mcolella14#8 from mcolella14/playwright-support
Playwright support
2 parents a25fd1e + 9321f97 commit a42f81b

22 files changed

+883
-444
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,6 @@ dmypy.json
135135
.pytype/
136136

137137
# Cython debug symbols
138-
cython_debug/
138+
cython_debug/
139+
140+
.vscode

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include pyppeteer_ghost_cursor/js/*.js
1+
include python_ghost_cursor/js/*.js

README.md

+50-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
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.
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
8-
`pip install pyppeteer_ghost_cursor`
8+
`pip install python_ghost_cursor`
99

1010
## Usage
1111

1212
Generating movement data between 2 coordinates.
1313

1414
```python
15-
from pyppeteer_ghost_cursor import path
15+
from python_ghost_cursor import path
1616

1717
start = {
1818
"x": 220,
@@ -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 python_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 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+
5478
```
5579

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+
```
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

pyppeteer_ghost_cursor/__init__.py

-7
This file was deleted.

pyppeteer_ghost_cursor/js/mouseHelper.js

-103
This file was deleted.

pyppeteer_ghost_cursor/mouseHelper.py

-9
This file was deleted.

0 commit comments

Comments
 (0)