MCPcopy Create free account
hub / github.com/antonis19/autobrowse / fetch_html

Method fetch_html

retrieve_html_proxy_agent.py:83–98  ·  view source on GitHub ↗

Fetch the HTML of the current page from the browser console

(self, **kwargs)

Source from the content-addressed store, hash-verified

81
82 def connect_websocket(self):
83 self.websocket = asyncio.get_event_loop().run_until_complete(websockets.connect(self.browser_console_uri))
84
85 async def fetch_html(self, **kwargs) -> str:
86 '''
87 Fetch the HTML of the current page from the browser console
88 '''
89 if not self.websocket:
90 self.websocket = websockets.connect(self.browser_console_uri)
91 print(f"Fetching HTML of current page...")
92 message = json.dumps({
93 'action': "fetchHTML",
94 })
95
96 await self.websocket.send(message)
97 response_data = json.loads(await self.websocket.recv())
98 if not response_data.get('success'):
99 raise Exception("Failed to fetch HTML")
100 return response_data["result"]
101

Callers 1

Calls 1

sendMethod · 0.80

Tested by

no test coverage detected