MCPcopy
hub / github.com/stitionai/devika / crawl

Method crawl

src/browser/interaction.py:231–483  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

229 self.page.keyboard.press("Enter")
230
231 def crawl(self):
232 page = self.page
233 page_element_buffer = self.page_element_buffer
234 start = time.time()
235
236 page_state_as_text = []
237
238 device_pixel_ratio = page.evaluate("window.devicePixelRatio")
239 if platform == "darwin" and device_pixel_ratio == 1: # lies
240 device_pixel_ratio = 2
241
242 win_scroll_x = page.evaluate("window.scrollX")
243 win_scroll_y = page.evaluate("window.scrollY")
244 win_upper_bound = page.evaluate("window.pageYOffset")
245 win_left_bound = page.evaluate("window.pageXOffset")
246 win_width = page.evaluate("window.screen.width")
247 win_height = page.evaluate("window.screen.height")
248 win_right_bound = win_left_bound + win_width
249 win_lower_bound = win_upper_bound + win_height
250 document_offset_height = page.evaluate("document.body.offsetHeight")
251 document_scroll_height = page.evaluate("document.body.scrollHeight")
252
253 # Removed unused percentage_progress variables
254
255 tree = self.client.send(
256 "DOMSnapshot.captureSnapshot",
257 {"computedStyles": [], "includeDOMRects": True, "includePaintOrder": True},
258 )
259 strings = tree["strings"]
260 document = tree["documents"][0]
261 nodes = document["nodes"]
262 backend_node_id = nodes["backendNodeId"]
263 attributes = nodes["attributes"]
264 node_value = nodes["nodeValue"]
265 parent = nodes["parentIndex"]
266 node_types = nodes["nodeType"]
267 node_names = nodes["nodeName"]
268 is_clickable = set(nodes["isClickable"]["index"])
269
270 text_value = nodes["textValue"]
271 text_value_index = text_value["index"]
272 text_value_values = text_value["value"]
273
274 input_value = nodes["inputValue"]
275 input_value_index = input_value["index"]
276 input_value_values = input_value["value"]
277
278 input_checked = nodes["inputChecked"]
279 layout = document["layout"]
280 layout_node_index = layout["nodeIndex"]
281 bounds = layout["bounds"]
282
283 cursor = 0
284 html_elements_text = []
285
286 child_nodes = {}
287 elements_in_view_port = []
288

Callers 1

start_interactionFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected