Update app.py
Browse files
app.py
CHANGED
@@ -7,19 +7,27 @@ 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 |
-
|
12 |
-
|
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(
|
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 |
-
|
|
|
23 |
time.sleep(5)
|
24 |
txtcode = ""
|
25 |
#with open("datei.txt", "w") as f:
|
@@ -55,10 +63,8 @@ def selenium(message):
|
|
55 |
return result
|
56 |
|
57 |
iface = gr.Interface(
|
58 |
-
fn=
|
59 |
-
inputs=
|
60 |
-
gr.Textbox(label="Ort", value=""),
|
61 |
-
],
|
62 |
outputs=gr.Textbox(),
|
63 |
title="perplexity.ai",
|
64 |
description="get answer from perplexity"
|
|
|
7 |
from selenium.webdriver.support import expected_conditions as EC
|
8 |
from selenium.webdriver.chrome.options import Options
|
9 |
|
10 |
+
url = 'https://www.perplexity.ai'
|
11 |
+
options = webdriver.ChromeOptions()
|
12 |
+
options.add_argument('--headless')
|
13 |
+
wd = webdriver.Chrome(options=options)
|
14 |
+
wd.get(url)
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
def selenium(message):
|
19 |
+
|
20 |
+
#wd.implicitly_wait(3)
|
|
|
21 |
text_input = WebDriverWait(driver, 15).until(
|
22 |
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'))
|
23 |
)
|
24 |
+
text_input.send_keys(message)
|
25 |
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()
|
26 |
time.sleep(5)
|
27 |
|
28 |
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]')
|
29 |
+
text_el = txtelements.text
|
30 |
+
return text_el
|
31 |
time.sleep(5)
|
32 |
txtcode = ""
|
33 |
#with open("datei.txt", "w") as f:
|
|
|
63 |
return result
|
64 |
|
65 |
iface = gr.Interface(
|
66 |
+
fn=selenium,
|
67 |
+
inputs=gr.Textbox(label="Ort", value="")
|
|
|
|
|
68 |
outputs=gr.Textbox(),
|
69 |
title="perplexity.ai",
|
70 |
description="get answer from perplexity"
|