Skip to content

Commit ade334a

Browse files
committed
fix(docs): update Scrapybara migration examples per feedback
1 parent 63ce10a commit ade334a

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

migrations/scrapybara.mdx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ browser2 = await client.browsers.create(
143143

144144
### Computer Controls
145145

146-
Both Scrapybara and Kernel provide Computer Controls APIs that allow you to programmatically control the browser environment at the system level - including mouse movements, clicks, keyboard input, and screenshots. Kernel has expanded on this functionality with a comprehensive set of computer control methods.
146+
Both Scrapybara and Kernel provide Computer Controls APIs that allow you to programmatically control the browser environment at the system level - including mouse movements, clicks, keyboard input, and screenshots.
147147

148148
**Scrapybara**
149149
```python
@@ -166,38 +166,36 @@ screenshot = instance.browser.computer.take_screenshot()
166166

167167
**Kernel**
168168
```python
169-
browser = await client.browsers.create()
169+
kernel_browser = await client.browsers.create()
170170

171-
# Click at specific coordinates with additional options
171+
# Click at specific coordinates
172172
client.browsers.computer.click_mouse(
173-
id=browser.session_id,
173+
id=kernel_browser.session_id,
174174
x=100,
175-
y=200,
176-
button="left",
177-
click_type="click",
178-
num_clicks=1
175+
y=200
179176
)
180177

181178
# Drag from one position to another
182179
client.browsers.computer.drag_mouse(
183-
id=browser.session_id,
184-
from_x=100,
185-
from_y=100,
186-
to_x=200,
187-
to_y=200
180+
id=kernel_browser.session_id,
181+
path=[[100, 200], [150, 220], [200, 260]],
182+
button="left",
183+
delay=0,
184+
steps_per_segment=10,
185+
step_delay_ms=50,
186+
hold_keys=["Shift"]
188187
)
189188

190189
# Type text with optional delay
191190
client.browsers.computer.type_text(
192-
id=browser.session_id,
191+
id=kernel_browser.session_id,
193192
text="Hello World",
194193
delay=100
195194
)
196195

197-
# Take a screenshot (full screen or specific region)
196+
# Take a screenshot
198197
screenshot = client.browsers.computer.capture_screenshot(
199-
id=browser.session_id,
200-
region={"x": 0, "y": 0, "width": 800, "height": 600}
198+
id=kernel_browser.session_id
201199
)
202200
```
203201

0 commit comments

Comments
 (0)