File size: 756 Bytes
e2232d5 edee373 0cf0125 b4d814f 4baf418 edee373 ce23107 e77599e edee373 ce23107 edee373 ec32c39 edee373 ec32c39 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import os
#from html2image import Html2Image
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() |