It works like a charm now :)
Merged two projects and allowed them to use common functions for inter-operativity.
This commit is contained in:
20
bot/api/google.py
Normal file
20
bot/api/google.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import googlesearch
|
||||
|
||||
|
||||
def query(params):
|
||||
param_string = ""
|
||||
for word in params:
|
||||
param_string += word + "+"
|
||||
param_string = param_string[:-1]
|
||||
search_url = "https://google.com/search?q=" + param_string
|
||||
|
||||
try:
|
||||
res = googlesearch.search(param_string.replace("+"," ") ,num=5,start=0,stop=5)
|
||||
send_string = "Results for <b>" + param_string.replace("+"," ") + "</b>:\n\n"
|
||||
for url in res:
|
||||
send_string += url + "\n\n"
|
||||
send_string += "Search url:\n" + search_url
|
||||
except:
|
||||
send_string = "Search url:\n" + search_url
|
||||
|
||||
return send_string
|
||||
Reference in New Issue
Block a user