adpro commited on
Commit
155133d
·
verified ·
1 Parent(s): c0c6a1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -2,20 +2,20 @@ import requests
2
  import bs4
3
  import gradio as gr
4
  from bs4 import BeautifulSoup
 
5
 
6
  def run_lora(prompt,site,start,end):
7
- page = requests.get("https://www.google.com/search?q=inurl:" +site + " " +prompt + "&tbs=cdr%3A1%2Ccd_min%3A"+start+"%2Ccd_max%3A" + end)
8
- print("https://www.google.com/search?q=inurl:" +site + " " +prompt + "&tbs=cdr%3A1%2Ccd_min%3A"+start+"%2Ccd_max%3A" + end)
9
- soup = BeautifulSoup(page.content)
10
- features="html.parser"
11
- import re
12
- links = soup.findAll("a")
13
- mLink=""
14
- #for link in soup.find_all("a", "html.parser", parse_only=SoupStrainer('a')):
15
- for link in soup.find_all("a","html.parser",href=re.compile("(?<=/url\?q=)(htt.*://.*)")):
16
- print (re.split(":(?=http)",link["href"].replace("/url?q=","")))
17
- mLink+=str(re.split(":(?=http)",link["href"].replace("/url?q=","").replace("'","")))
18
- return mLink
19
 
20
  with gr.Blocks() as app:
21
  gr.HTML("""<html>
 
2
  import bs4
3
  import gradio as gr
4
  from bs4 import BeautifulSoup
5
+ from googlesearch import search
6
 
7
  def run_lora(prompt,site,start,end):
8
+
9
+
10
+
11
+
12
+ # to search
13
+ query = "https://www.google.com/search?q=inurl:" +site + " " +prompt + "&tbs=cdr%3A1%2Ccd_min%3A"+start+"%2Ccd_max%3A" + end
14
+
15
+ links = []
16
+ for j in search(query, tld="co.in", num=10, stop=10, pause=2):
17
+ links.append(j)
18
+ return links
 
19
 
20
  with gr.Blocks() as app:
21
  gr.HTML("""<html>