Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,22 +3,26 @@ import requests
|
|
3 |
|
4 |
|
5 |
def find_it(inp):
|
6 |
-
|
|
|
7 |
url = f"https://lens.google.com/uploadbyurl?url={inp}"
|
8 |
response = requests.get(url)
|
9 |
if response.status_code == 200:
|
10 |
page_content = response.text
|
11 |
|
12 |
soup = BeautifulSoup(page_content, "html.parser")
|
13 |
-
|
14 |
#articles = soup.find_all("div", class_="SoaBEf")
|
15 |
#articles = soup.find_all("a")
|
16 |
#articles = soup.find_all("article", class_="MQsxIb xTewfe R7GTQ keNKEd j7vNaf Cc0Z5d VkAdve GU7x0c JMJvke q4atFc")
|
17 |
articles = soup.find_all("article")
|
|
|
18 |
print (articles)
|
|
|
19 |
except Exception as e:
|
|
|
20 |
print (e)
|
21 |
-
|
22 |
#https://lens.google.com/uploadbyurl?url=
|
23 |
#https://tineye.com/search/?url=
|
24 |
#https://yandex.com/images/search?cbir_id=4330355%2FBhPd4CHqib3nxk9xOdS9pQ7899&rpt=imageview&url=
|
@@ -26,5 +30,7 @@ def find_it(inp):
|
|
26 |
|
27 |
with gr.Blocks() as app:
|
28 |
inp_url=gr.Textbox(label="Image URL")
|
|
|
29 |
inp_im=gr.Image()
|
|
|
30 |
app.launch()
|
|
|
3 |
|
4 |
|
5 |
def find_it(inp):
|
6 |
+
out=""
|
7 |
+
try:
|
8 |
url = f"https://lens.google.com/uploadbyurl?url={inp}"
|
9 |
response = requests.get(url)
|
10 |
if response.status_code == 200:
|
11 |
page_content = response.text
|
12 |
|
13 |
soup = BeautifulSoup(page_content, "html.parser")
|
14 |
+
print(soup.prettify())
|
15 |
#articles = soup.find_all("div", class_="SoaBEf")
|
16 |
#articles = soup.find_all("a")
|
17 |
#articles = soup.find_all("article", class_="MQsxIb xTewfe R7GTQ keNKEd j7vNaf Cc0Z5d VkAdve GU7x0c JMJvke q4atFc")
|
18 |
articles = soup.find_all("article")
|
19 |
+
out = soup.prettify
|
20 |
print (articles)
|
21 |
+
|
22 |
except Exception as e:
|
23 |
+
out = e
|
24 |
print (e)
|
25 |
+
return (out)
|
26 |
#https://lens.google.com/uploadbyurl?url=
|
27 |
#https://tineye.com/search/?url=
|
28 |
#https://yandex.com/images/search?cbir_id=4330355%2FBhPd4CHqib3nxk9xOdS9pQ7899&rpt=imageview&url=
|
|
|
30 |
|
31 |
with gr.Blocks() as app:
|
32 |
inp_url=gr.Textbox(label="Image URL")
|
33 |
+
go_btn=gr.Button()
|
34 |
inp_im=gr.Image()
|
35 |
+
go_btn.click(find_it,inp_url,outp_text)
|
36 |
app.launch()
|