This repository has been archived on 2023-04-13. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
CloudBot/plugins/urlparse.py
2012-09-05 07:52:03 +12:00

21 lines
419 B
Python
Executable file

from util import hook, http, urlnorm
@hook.command
def title(inp):
"title <url> -- gets the title of a web page"
url = urlnorm.normalize(inp.encode('utf-8'))
try:
page = http.get_html(url)
except:
return "Could not fetch page."
try:
title = page.find(".//title").text
except:
return "Could not find title."
title = http.unescape(title)
return title