File size: 1,695 Bytes
c3b7bd1 f542379 c3b7bd1 98f4628 5e2d069 c3b7bd1 c5306b6 c34c062 9c0c9be cbe5fd2 9c0c9be 5e2d069 9c0c9be aaf1edb 0a86f66 0a37457 8177bb7 0a37457 8177bb7 382626b 8177bb7 c3b7bd1 9c0c9be 0a86f66 9c0c9be be3b188 98f4628 9c0c9be 60bc03e c3b7bd1 5e2d069 c3b7bd1 9c0c9be |
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
import gradio as gr
from selenium import webdriver
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.common.by import By
def take_screenshots(ort, start, end, step):
options = webdriver.ChromeOptions()
options.add_argument('--headless')
wd = webdriver.Chrome(options=options)
results = []
for i in range(start, end + 1, step):
url = f"https://www.google.com/search?q=vereine+{ort}&start={i}"
wd.get(url)
wd.implicitly_wait(3)
try:
element = wd.find_element(By.TAG_NAME, "body")
body_text = element.text
results.append(body_text)
except Exception as e:
print(f"Error fetching data from {url}: {e}")
wd.quit()
#erg ="\n".join(results)
#erg=results[0]
#return "\n".join(results)
result = client.predict(
query=f"erstelle ein json objekt für die vereine: \n{''.join(results)}",
#query=f"wie hoch ist der kölner dom",
history=[],
system="You are Qwen, created by Alibaba Cloud. You are a helpful assistant.",
api_name="/model_chat"
)
result = result[1]
result = result[0][1]
result=gr.Markdown(result)
return result
iface = gr.Interface(
fn=take_screenshots,
inputs=[
gr.Textbox(label="Ort", value=""),
gr.Number(label="Start Index", value=10),
gr.Number(label="Anzahl Vereine", value=100),
gr.Number(label="Step", value=10),
],
outputs=gr.Textbox(),
title="Website Screenshot",
description="Take screenshots of websites in specified range and step size for a given location."
)
iface.launch() |