mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-05-06 11:33:42 -05:00
remove gsearch use soup
This commit is contained in:
parent
62c339cdc2
commit
c3658c182c
@ -15,7 +15,6 @@ import requests
|
|||||||
import re
|
import re
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from fake_useragent import UserAgent
|
from fake_useragent import UserAgent
|
||||||
from gsearch.googlesearch import search
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from supybot.i18n import PluginInternationalization
|
from supybot.i18n import PluginInternationalization
|
||||||
@ -29,22 +28,23 @@ class WikiLeaf(callbacks.Plugin):
|
|||||||
"""Retrieve Marjuana Strain Information From WikiLeaf"""
|
"""Retrieve Marjuana Strain Information From WikiLeaf"""
|
||||||
threaded = True
|
threaded = True
|
||||||
|
|
||||||
def dosearch(self, strain):
|
def dosearch(self, search):
|
||||||
data = search("{0} site:wikileaf.com/strain/".format(strain))
|
searchurl = "https://www.google.com/search?&q={0} site:wikileaf.com/strain/".format(search)
|
||||||
title, url = data[0]
|
ua = UserAgent()
|
||||||
|
header = {'User-Agent':str(ua.random)}
|
||||||
|
data = requests.get(searchurl, headers=header)
|
||||||
|
soup = BeautifulSoup(data.text)
|
||||||
|
url = soup.find('cite').getText()
|
||||||
|
title = soup.find("h3").getText()
|
||||||
return title, url
|
return title, url
|
||||||
|
|
||||||
def strain(self, irc, msg, args, strain):
|
def strain(self, irc, msg, args, strain):
|
||||||
"""<strain>
|
"""<strain>
|
||||||
Returns strain information from WikiLeaf. Search powered by Google.
|
Returns strain information from WikiLeaf. Search powered by Google.
|
||||||
"""
|
"""
|
||||||
retries = 0
|
title, url = self.dosearch(strain)
|
||||||
url = None
|
irc.reply(title)
|
||||||
while not url and retries <= 3:
|
irc.reply(url)
|
||||||
try:
|
|
||||||
title, url = self.dosearch(strain)
|
|
||||||
except:
|
|
||||||
retries +=1
|
|
||||||
if url:
|
if url:
|
||||||
ua = UserAgent()
|
ua = UserAgent()
|
||||||
header = {'User-Agent':str(ua.random)}
|
header = {'User-Agent':str(ua.random)}
|
||||||
@ -62,3 +62,4 @@ class WikiLeaf(callbacks.Plugin):
|
|||||||
strain = wrap(strain, ['text'])
|
strain = wrap(strain, ['text'])
|
||||||
|
|
||||||
Class = WikiLeaf
|
Class = WikiLeaf
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user