Spaces:
Build error
Build error
Commit ·
a69d7e3
1
Parent(s): fe09394
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,7 +38,6 @@ def cause(img):
|
|
| 38 |
src = page.content
|
| 39 |
soup=BeautifulSoup(src, "lxml")
|
| 40 |
details=[url,]
|
| 41 |
-
#details=[]
|
| 42 |
for elem in soup.find_all("div",{'class':'post-entry'}):
|
| 43 |
ol = elem.find('ol')
|
| 44 |
if ol:
|
|
@@ -48,8 +47,7 @@ def cause(img):
|
|
| 48 |
#SUGGESTIONS
|
| 49 |
url2 = 'https://google.com/search?q=treatment+' + res
|
| 50 |
request_result=requests.get(url2)
|
| 51 |
-
soup = bs4.BeautifulSoup(request_result.text,
|
| 52 |
-
"html.parser")
|
| 53 |
links = soup.find_all("a")
|
| 54 |
suggestions=[]
|
| 55 |
for link in links:
|
|
@@ -57,8 +55,6 @@ def cause(img):
|
|
| 57 |
if "url?q=" in link_href and not "webcache" in link_href:
|
| 58 |
title = link.find_all('h3', limit=3)
|
| 59 |
if len(title)> 0:
|
| 60 |
-
#suggestions.append(title[0].getText())
|
| 61 |
-
#suggestions.append(link.get('href').split("?q=")[1].split("&sa=U")[0])
|
| 62 |
suggestions.append(title[0].getText()+" "+link.get('href').split("?q=")[1].split("&sa=U")[0])
|
| 63 |
|
| 64 |
|
|
@@ -91,7 +87,7 @@ def cause(img):
|
|
| 91 |
elif res == "mosaic-virus":
|
| 92 |
cause = "the cause is that aphid activity in fields is high"
|
| 93 |
sug=listToString(suggestions)
|
| 94 |
-
return(cause,
|
| 95 |
else:
|
| 96 |
text = "Undetected disease"
|
| 97 |
cause = "unknown"
|
|
|
|
| 38 |
src = page.content
|
| 39 |
soup=BeautifulSoup(src, "lxml")
|
| 40 |
details=[url,]
|
|
|
|
| 41 |
for elem in soup.find_all("div",{'class':'post-entry'}):
|
| 42 |
ol = elem.find('ol')
|
| 43 |
if ol:
|
|
|
|
| 47 |
#SUGGESTIONS
|
| 48 |
url2 = 'https://google.com/search?q=treatment+' + res
|
| 49 |
request_result=requests.get(url2)
|
| 50 |
+
soup = bs4.BeautifulSoup(request_result.text,"html.parser")
|
|
|
|
| 51 |
links = soup.find_all("a")
|
| 52 |
suggestions=[]
|
| 53 |
for link in links:
|
|
|
|
| 55 |
if "url?q=" in link_href and not "webcache" in link_href:
|
| 56 |
title = link.find_all('h3', limit=3)
|
| 57 |
if len(title)> 0:
|
|
|
|
|
|
|
| 58 |
suggestions.append(title[0].getText()+" "+link.get('href').split("?q=")[1].split("&sa=U")[0])
|
| 59 |
|
| 60 |
|
|
|
|
| 87 |
elif res == "mosaic-virus":
|
| 88 |
cause = "the cause is that aphid activity in fields is high"
|
| 89 |
sug=listToString(suggestions)
|
| 90 |
+
return(cause,details,sug)
|
| 91 |
else:
|
| 92 |
text = "Undetected disease"
|
| 93 |
cause = "unknown"
|