| import os |
| |
| import gradio as gr |
| print(os.environ) |
|
|
| import asyncio |
| os.system('playwright install') |
| os.system('playwright install-deps') |
|
|
| from playwright.async_api import async_playwright |
|
|
|
|
|
|
| async def main(inp): |
| async with async_playwright() as p: |
| browser = await p.chromium.launch() |
| page = await browser.new_page() |
| await page.goto('https://www.bbc.co.uk/news/business-63709754') |
| await page.locator('.ssrcss-hmf8ql-BoldText').screenshot(path='element.png') |
| await browser.close() |
| return ("done",'element.png') |
|
|
|
|
| with gr.Blocks() as app: |
| inp=gr.Textbox(lines=6) |
| btn=gr.Button() |
| outhtml=gr.HTML() |
| outp=gr.Image() |
| btn.click(main,inp,[outhtml,outp]) |
| app.launch() |