Update app.py
Browse files
app.py
CHANGED
@@ -3,32 +3,38 @@ from selenium import webdriver
|
|
3 |
from selenium.common.exceptions import WebDriverException
|
4 |
from selenium.webdriver.common.by import By
|
5 |
from gradio_client import Client
|
|
|
|
|
|
|
6 |
|
7 |
-
|
8 |
-
def take_screenshots(ort, start, end, step):
|
9 |
options = webdriver.ChromeOptions()
|
10 |
options.add_argument('--headless')
|
11 |
wd = webdriver.Chrome(options=options)
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
31 |
|
|
|
|
|
|
|
32 |
wd.quit()
|
33 |
#erg ="\n".join(results)
|
34 |
#return erg
|
@@ -52,13 +58,10 @@ iface = gr.Interface(
|
|
52 |
fn=take_screenshots,
|
53 |
inputs=[
|
54 |
gr.Textbox(label="Ort", value=""),
|
55 |
-
gr.Number(label="Start Index", value=10),
|
56 |
-
gr.Number(label="Anzahl Vereine", value=100),
|
57 |
-
gr.Number(label="Step", value=10),
|
58 |
],
|
59 |
outputs=gr.Textbox(),
|
60 |
-
title="
|
61 |
-
description="
|
62 |
)
|
63 |
|
64 |
iface.launch()
|
|
|
3 |
from selenium.common.exceptions import WebDriverException
|
4 |
from selenium.webdriver.common.by import By
|
5 |
from gradio_client import Client
|
6 |
+
from selenium.webdriver.support.wait import WebDriverWait
|
7 |
+
from selenium.webdriver.support import expected_conditions as EC
|
8 |
+
from selenium.webdriver.chrome.options import Options
|
9 |
|
10 |
+
def selenium(message):
|
|
|
11 |
options = webdriver.ChromeOptions()
|
12 |
options.add_argument('--headless')
|
13 |
wd = webdriver.Chrome(options=options)
|
14 |
+
text_input = WebDriverWait(driver, 15).until(
|
15 |
+
EC.presence_of_element_located((By.XPATH, '/html/body/main/div/div/div[2]/div[1]/div/div[3]/div/div/div[2]/div[2]/div/div/span/div/div/div/div[1]/textarea'))
|
16 |
+
)
|
17 |
+
text_input.send_keys(prompt)
|
18 |
+
button_send = driver.find_element(By.XPATH, '/html/body/main/div/div/div[2]/div[1]/div/div[3]/div/div/div[2]/div[2]/div/div/span/div/div/div/div[3]/button').click()
|
19 |
+
time.sleep(5)
|
|
|
20 |
|
21 |
+
txtelements = driver.find_elements(By.XPATH, '/html/body/main/div/div/div[2]/div[1]/div/div[3]/div/div[1]/div/div[2]/div/div[1]/div[2]/div[2]/div[2]')
|
22 |
+
#text_el = txtelements.text
|
23 |
+
time.sleep(5)
|
24 |
+
txtcode = ""
|
25 |
+
#with open("datei.txt", "w") as f:
|
26 |
+
#f.write(code)
|
27 |
+
#response_code = {"result": code}
|
28 |
+
#json.dump(response_code, open('code.json', 'w'), indent=4, sort_keys=True)
|
29 |
+
for e in txtelements:
|
30 |
+
txtcode += e.text
|
31 |
+
#response_txt = {"result": txtcode}
|
32 |
+
#print(code)
|
33 |
+
print(txtcode)
|
34 |
|
35 |
+
#json.dump(response_txt, open('text.json', 'w'), indent=4, sort_keys=True)
|
36 |
+
#json.dump(response_code, open('code.json', 'w'), indent=4, sort_keys=True)
|
37 |
+
return txtcode
|
38 |
wd.quit()
|
39 |
#erg ="\n".join(results)
|
40 |
#return erg
|
|
|
58 |
fn=take_screenshots,
|
59 |
inputs=[
|
60 |
gr.Textbox(label="Ort", value=""),
|
|
|
|
|
|
|
61 |
],
|
62 |
outputs=gr.Textbox(),
|
63 |
+
title="perplexity.ai",
|
64 |
+
description="get answer from perplexity"
|
65 |
)
|
66 |
|
67 |
iface.launch()
|