mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-04-27 13:31:10 -05:00
DDG: make _ddgurl() a static method
This commit is contained in:
parent
8187d51cef
commit
d332e73e48
@ -33,6 +33,7 @@ from supybot.commands import *
|
|||||||
import supybot.plugins as plugins
|
import supybot.plugins as plugins
|
||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
import supybot.log as log
|
||||||
try:
|
try:
|
||||||
from supybot.i18n import PluginInternationalization
|
from supybot.i18n import PluginInternationalization
|
||||||
_ = PluginInternationalization('DDG')
|
_ = PluginInternationalization('DDG')
|
||||||
@ -59,11 +60,12 @@ class DDG(callbacks.Plugin):
|
|||||||
"""Searches for results on DuckDuckGo."""
|
"""Searches for results on DuckDuckGo."""
|
||||||
threaded = True
|
threaded = True
|
||||||
|
|
||||||
def _ddgurl(self, text):
|
@staticmethod
|
||||||
|
def _ddgurl(text):
|
||||||
# DuckDuckGo has a 'lite' site free of unparseable JavaScript
|
# DuckDuckGo has a 'lite' site free of unparseable JavaScript
|
||||||
# elements, so we'll use that to our advantage!
|
# elements, so we'll use that to our advantage!
|
||||||
url = "https://duckduckgo.com/lite?" + urlencode({"q": text})
|
url = "https://duckduckgo.com/lite?" + urlencode({"q": text})
|
||||||
self.log.debug("DDG: Using URL %s for search %s", url, text)
|
log.debug("DDG: Using URL %s for search %s", url, text)
|
||||||
data = utils.web.getUrl(url).decode("utf-8")
|
data = utils.web.getUrl(url).decode("utf-8")
|
||||||
soup = BeautifulSoup(data)
|
soup = BeautifulSoup(data)
|
||||||
# Remove "sponsored link" results
|
# Remove "sponsored link" results
|
||||||
|
Loading…
x
Reference in New Issue
Block a user