Commit 62a69b33 authored by Svetlana Tkachenko's avatar Svetlana Tkachenko
Browse files

parse html in google search results title (for issue #25)

parent c257c196
......@@ -23,6 +23,7 @@
import urllib.request, urllib.parse
import json
import html.parser
@plugin
class Google(object):
......@@ -30,6 +31,7 @@ class Google(object):
def __init__(self, server):
self.commands = ["google", "g"]
self.server = server
self.h = html.parser.HTMLParser()
self.server.handle("command", self.handle_command, self.commands)
def handle_command(self, channel, user, cmd, args):
......@@ -41,4 +43,6 @@ class Google(object):
results = data['responseData']['results']
if(len(results)>0):
result1=results[0]
self.server.doMessage(channel, result1['titleNoFormatting'] + ' - ' + result1['unescapedUrl'])
title = result1['titleNoFormatting']
title = self.h.unescape(title)
self.server.doMessage(channel, title + ' - ' + result1['unescapedUrl'])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment