I have this code and want to integrate amqplib to take screenshots. I want to send this…
- User
I have this code and want to integrate amqplib to take screenshots. I want to send this link from python using python pika and on new messages, the amqplib should open that link and take screenshot and save it.
The link I want to send from python pika : "https://www.google.com/maps/dir/?api=1&origin=18.759087,75.031946&destination=11.556697,79.549632&travelmode=driving"
My current code where I want amqplib integrated : "from playwright.sync_api import sync_playwright
def take_screenshot_with_user_agent(url, output_path, user_agent): with sync_playwright() as p: browser = p.chromium.launch() context = browser.new_context(user_agent=user_agent) page = context.new_page() page.goto(url) page.wait_for_load_state("networkidle") page.screenshot(path=output_path) browser.close()
Usage
samsung_user_agent = "Mozilla/5.0 (Linux; Android 11; SM-G991U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.210 Mobile Safari/537.36" take_screenshot_with_user_agent('https://www.google.com/maps/dir/Chennai,+Tamil+Nadu/Puducherry/@12.4912544,79.2258202,9z/data=!3m1!4b1!4m13!4m12!1m5!1m1!1s0x3a5265ea4f7d3361:0x6e61a70b6863d433!2m2!1d80.2704622!2d13.0843007!1m5!1m1!1s0x3a5361ab8e49cfcf:0xcc6bd326d2f0b04e!2m2!1d79.8083133!2d11.9415915?entry=ttu', '/screenshots/screenshot.png', samsung_user_agent) "
The script should launch playwright browser on inital run and keep it without closing and keep taking screenshots and save it on every new message sent through amqp
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.