Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,11 +9,39 @@ from urllib.parse import parse_qs
|
|
9 |
|
10 |
def run_lora(prompt,site,start,end):
|
11 |
|
12 |
-
j =
|
13 |
links=""
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
with gr.Blocks() as app:
|
19 |
gr.HTML("""<html>
|
|
|
9 |
|
10 |
def run_lora(prompt,site,start,end):
|
11 |
|
12 |
+
j = "inurl:"+site +"+"+ prompt + "&tbs=cdr%3A1%2Ccd_min%3A"+start+"%2Ccd_max%3A" + end,proxy="https://proxyhere.net:port")
|
13 |
links=""
|
14 |
+
|
15 |
+
page = requests.get(j, headers = {'User-agent': 'your bot 0.1'})
|
16 |
+
soup = BeautifulSoup(page.content,"html.parser")
|
17 |
+
mj = extract_results(soup)
|
18 |
+
print(mj)
|
19 |
+
def extract_results(soup):
|
20 |
+
main = soup.select_one("#main")
|
21 |
+
|
22 |
+
res = []
|
23 |
+
for gdiv in main.select('.g, .fP1Qef'):
|
24 |
+
res.append(extract_section(gdiv))
|
25 |
+
return res
|
26 |
+
|
27 |
+
def extract_section(gdiv):
|
28 |
+
# Getting our elements
|
29 |
+
title = gdiv.select_one('h3')
|
30 |
+
link = gdiv.select_one('a')
|
31 |
+
description = gdiv.find('.BNeawe')
|
32 |
+
return {
|
33 |
+
# Extract title's text only if text is found
|
34 |
+
'title': title.text if title else None,
|
35 |
+
|
36 |
+
'link': link['href'] if link else None,
|
37 |
+
'description': description.text if description else None
|
38 |
+
}
|
39 |
+
def extract_href(href):
|
40 |
+
url = urlparse(href)
|
41 |
+
query = parse_qs(url.query)
|
42 |
+
if not ('q' in query and query['q'] and len(query['q']) > 0):
|
43 |
+
return None
|
44 |
+
return query['q'][0]
|
45 |
|
46 |
with gr.Blocks() as app:
|
47 |
gr.HTML("""<html>
|