adpro commited on
Commit
a4601fc
·
verified ·
1 Parent(s): 958ec68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -20,9 +20,18 @@ def run_lora(prompt,site,start,end):
20
  mLink=""
21
  #for link in soup.find_all("a", "html.parser", parse_only=SoupStrainer('a')):
22
  for link in soup.find_all("a",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>
 
20
  mLink=""
21
  #for link in soup.find_all("a", "html.parser", parse_only=SoupStrainer('a')):
22
  for link in soup.find_all("a",href=re.compile("(?<=/url\?q=)(htt.*://.*)")):
23
+ #print (re.split(":(?=http)",link["href"].replace("/url?q=","")))
24
+ jj = extract_href(link["href"])
25
+ print(jj)
26
  mLink+=str(re.split(":(?=http)",link["href"].replace("/url?q=","").replace("'","")))
27
 
28
+
29
+ def extract_href(href):
30
+ url = urlparse(href)
31
+ query = parse_qs(url.query)
32
+ if not ('q' in query and query['q'] and len(query['q']) > 0):
33
+ return None
34
+ return query['q'][0]
35
 
36
  with gr.Blocks() as app:
37
  gr.HTML("""<html>