This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/plugins/urlparse.py

22 lines
419 B
Python
Raw Normal View History

2012-05-16 21:45:59 +02:00
from util import hook, http, urlnorm
2011-11-20 10:23:31 +01:00
2012-03-23 06:14:58 +01:00
@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."
2012-03-23 06:14:58 +01:00
try:
title = page.find(".//title").text
except:
return "Could not find title."
title = http.unescape(title)
2012-03-23 06:14:58 +01:00
2012-09-04 21:52:03 +02:00
return title