adpro commited on
Commit
e1c3f57
·
verified ·
1 Parent(s): 3ef2177

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -25
app.py CHANGED
@@ -16,37 +16,13 @@ def run_lora(prompt,site,start,end):
16
  soup = BeautifulSoup(page.content,"html.parser")
17
  import re
18
  links = soup.findAll("a")
 
19
  mLink=""
20
  #for link in soup.find_all("a", "html.parser", parse_only=SoupStrainer('a')):
21
  for link in soup.find_all("a","html.parser",href=re.compile("(?<=/url\?q=)(htt.*://.*)")):
22
  print (re.split(":(?=http)",link["href"].replace("/url?q=","")))
23
  mLink+=str(re.split(":(?=http)",link["href"].replace("/url?q=","").replace("'","")))
24
- def extract_results(soup):
25
- main = soup.select_one("#main")
26
 
27
- res = []
28
- for gdiv in main.select('.e9EfHf, .s6JM6d'):
29
- res.append(extract_section(gdiv))
30
- return res
31
-
32
- def extract_section(gdiv):
33
- # Getting our elements
34
- title = gdiv.select_one('h3')
35
- link = gdiv.select_one('a')
36
- description = gdiv.find('.BNeawe')
37
- return {
38
- # Extract title's text only if text is found
39
- 'title': title.text if title else None,
40
-
41
- 'link': link['href'] if link else None,
42
- 'description': description.text if description else None
43
- }
44
- def extract_href(href):
45
- url = urlparse(href)
46
- query = parse_qs(url.query)
47
- if not ('q' in query and query['q'] and len(query['q']) > 0):
48
- return None
49
- return query['q'][0]
50
 
51
  with gr.Blocks() as app:
52
  gr.HTML("""<html>
 
16
  soup = BeautifulSoup(page.content,"html.parser")
17
  import re
18
  links = soup.findAll("a")
19
+ print(links)
20
  mLink=""
21
  #for link in soup.find_all("a", "html.parser", parse_only=SoupStrainer('a')):
22
  for link in soup.find_all("a","html.parser",href=re.compile("(?<=/url\?q=)(htt.*://.*)")):
23
  print (re.split(":(?=http)",link["href"].replace("/url?q=","")))
24
  mLink+=str(re.split(":(?=http)",link["href"].replace("/url?q=","").replace("'","")))
 
 
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  with gr.Blocks() as app:
28
  gr.HTML("""<html>