import asyncio from pyppeteer import launch async def get_element_html(url, x, y): # const browser = await puppeteer.launch( {"headless": false, args: ['--start-maximized'] } ); browser = await launch() page = await browser.newPage() await page.setViewport({'width': 3072, 'height': 1920}) await page.goto(url) # Get the HTML element at the specified (x, y) coordinate element = await page.evaluate( '''(x, y) => { const element = document.elementFromPoint(x, y); return element ? element.outerHTML : null; }''', x, y ) await browser.close() return element async def save_html_to_file(html, filename): with open(filename, 'w') as file: file.write(html) async def main(): url = input("Enter URL: ") x = int(input("Enter X coordinate: ")) y = int(input("Enter Y coordinate: ")) filename = f'at{x}and{y}.html' html = await get_element_html(url, x, y) await save_html_to_file(html, filename) print("HTML saved to", filename) asyncio.run(main())