Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,20 +8,27 @@ from googlesearch import search
|
|
| 8 |
from urllib.parse import parse_qs
|
| 9 |
|
| 10 |
def run_lora(prompt,site,start,end):
|
|
|
|
|
|
|
|
|
|
| 11 |
murl = "https://www.google.com/search?q=site:" +site + " " +prompt + "&sca_esv=9a56963d0daaccd0&sca_upv=1&tbs=cdr%3A1%2Ccd_min%3A"+start+"%2Ccd_max%3A" + end
|
| 12 |
surl = "https://www.google.com/search?q=site:" +site + " " +prompt + "after:"+start+"before:" + end
|
| 13 |
page = requests.get(murl)
|
| 14 |
print("https://www.google.com/search?q=site:" +site + " " +prompt + "&tbs=cdr%3A1%2Ccd_min%3A"+start+"%2Ccd_max%3A" + end)
|
| 15 |
-
soup = BeautifulSoup(page.
|
| 16 |
import re
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
def extract_href(href):
|
| 27 |
url = urlparse(href)
|
|
|
|
| 8 |
from urllib.parse import parse_qs
|
| 9 |
|
| 10 |
def run_lora(prompt,site,start,end):
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
|
| 14 |
murl = "https://www.google.com/search?q=site:" +site + " " +prompt + "&sca_esv=9a56963d0daaccd0&sca_upv=1&tbs=cdr%3A1%2Ccd_min%3A"+start+"%2Ccd_max%3A" + end
|
| 15 |
surl = "https://www.google.com/search?q=site:" +site + " " +prompt + "after:"+start+"before:" + end
|
| 16 |
page = requests.get(murl)
|
| 17 |
print("https://www.google.com/search?q=site:" +site + " " +prompt + "&tbs=cdr%3A1%2Ccd_min%3A"+start+"%2Ccd_max%3A" + end)
|
| 18 |
+
soup = BeautifulSoup(page.text,'html.parser')
|
| 19 |
import re
|
| 20 |
+
search_results = []
|
| 21 |
+
for g in soup.find_all('div', class_='tF2Cxc'):
|
| 22 |
+
title = g.find('h3').text if g.find('h3') else 'No title'
|
| 23 |
+
link = g.find('a')['href']
|
| 24 |
+
snippet = g.find('div', class_='IsZvec').text if g.find('div', class_='IsZvec') else 'No snippet'
|
| 25 |
+
search_results.append({
|
| 26 |
+
'title': title,
|
| 27 |
+
'link': link,
|
| 28 |
+
'snippet': snippet
|
| 29 |
+
})
|
| 30 |
+
|
| 31 |
+
return search_results
|
| 32 |
|
| 33 |
def extract_href(href):
|
| 34 |
url = urlparse(href)
|