Update app.py
Browse files
app.py
CHANGED
@@ -33,6 +33,26 @@ def wiki(name):
|
|
33 |
continue
|
34 |
return out
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
def greet(name1):
|
37 |
name = name1.lower()
|
38 |
#n=
|
@@ -52,7 +72,7 @@ def greet(name1):
|
|
52 |
return "Im not a human so i don't have age"
|
53 |
if "thank u" in name or "thanks" in name or "thank you" in name:
|
54 |
return "ok welcome ....!"
|
55 |
-
return
|
56 |
|
57 |
|
58 |
|
@@ -63,30 +83,7 @@ def greet(name1):
|
|
63 |
|
64 |
|
65 |
|
66 |
-
|
67 |
-
url = "https://www.google.com/search?q="+name
|
68 |
-
r = requests.get(url)
|
69 |
-
|
70 |
-
soup = BeautifulSoup(r.text,"html.parser")
|
71 |
-
|
72 |
-
heading_object=soup.find_all('div')
|
73 |
-
n=1
|
74 |
-
for info in heading_object:
|
75 |
-
|
76 |
-
n=n+1
|
77 |
-
p=""
|
78 |
-
if n==9:
|
79 |
-
#print("------",n)
|
80 |
-
result = info.getText()[170:]
|
81 |
-
result = result.split(".")
|
82 |
-
for s in result[:10]:
|
83 |
-
p = p + "\n"+s
|
84 |
-
p = p.replace("org › wiki ›","")
|
85 |
-
p = p.replace("wikipedia","")
|
86 |
-
p = p.replace("com › dictionary ›","")
|
87 |
-
print(p)
|
88 |
-
return p
|
89 |
-
break
|
90 |
|
91 |
|
92 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
|
|
33 |
continue
|
34 |
return out
|
35 |
|
36 |
+
def google(name):
|
37 |
+
result = {"",""}
|
38 |
+
text = ""
|
39 |
+
url = "https://www.google.com/search?q="+name
|
40 |
+
r = requests.get(url)
|
41 |
+
|
42 |
+
soup = BeautifulSoup(r.text,"html.parser")
|
43 |
+
|
44 |
+
heading_object=soup.find_all('div')
|
45 |
+
n=1
|
46 |
+
for info in heading_object:
|
47 |
+
|
48 |
+
n=n+1
|
49 |
+
if '<div class="BNeawe s3v9rd AP7Wnd"><div><div><div class="BNeawe s3v9rd AP7Wnd">' in str(info):
|
50 |
+
if '›' not in str(info.text) :
|
51 |
+
result.add(info.text)
|
52 |
+
for i in result:
|
53 |
+
text = text +i+"\n"
|
54 |
+
return text
|
55 |
+
|
56 |
def greet(name1):
|
57 |
name = name1.lower()
|
58 |
#n=
|
|
|
72 |
return "Im not a human so i don't have age"
|
73 |
if "thank u" in name or "thanks" in name or "thank you" in name:
|
74 |
return "ok welcome ....!"
|
75 |
+
return google(name)
|
76 |
|
77 |
|
78 |
|
|
|
83 |
|
84 |
|
85 |
|
86 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
|
89 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|