From d77dd8b828d14bddeb0601d526f606dc8a3844b9 Mon Sep 17 00:00:00 2001 From: aewens Date: Thu, 15 Nov 2018 17:34:10 -0500 Subject: [PATCH] Added get_title --- bot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index b2d491b..6ac7955 100644 --- a/bot.py +++ b/bot.py @@ -1,4 +1,5 @@ import teambot, time, datastore +import lxml.html USAGE = dict(admin="Stop trying to use this command!",sotd="{}sotd ",listsotd="{}listsotd") PUBLIC_COMMANDS = ["sotd","listsotd"] @@ -6,7 +7,8 @@ PUBLIC_COMMANDS = ["sotd","listsotd"] SOTDS = datastore.DataStore("sotd.json") def get_title(link): - return link # TODO: actually make this get the title of a link. + page = lxml.html.parse(link) + return page.find(".//title").text class SOTDBot(teambot.Handler,teambot.CommandHandlerMixin): def __init__(self,*args):