chatcode / app.py
Arafath10's picture
Update app.py
76a3288
raw
history blame
1.14 kB
import gradio as gr
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from chatterbot.trainers import ChatterBotCorpusTrainer
import wikipedia
import requests
from bs4 import BeautifulSoup
def qq():
#text = chatbot.get_response(name)
name = name.lower()
if "what" in name or "who" in name or "how to" in name:
result = wikipedia.summary(name, sentences =10)
return result
else:
return "no found"
def greet(name):
url = "https://www.google.com/search?q="+name
r = requests.get(url)
soup = BeautifulSoup(r.text,"html.parser")
heading_object=soup.find_all('div')
n=1
for info in heading_object:
n=n+1
p=""
if n==9:
print("------",n)
result = info.getText()[182:]
result = result.split(".")
for s in result[:-20]:
p = p + s+"\n"
return p
break
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch()