Guest User

Untitled

a guest
Oct 18th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import re
  2. from util import hook, urlnorm, http
  3.  
  4. @hook.regex(r'([a-zA-Z]+://|www\.)[^ ]+')
  5. def show_title(match, nick='', chan='', say=None):
  6. url = urlnorm.normalize(match.group().encode('utf-8'))
  7. page = http.get_html(url)
  8. title = page.xpath('//title')
  9. if title:
  10. titleList = []
  11. for i in title:
  12. if i.text_content():
  13. titleList.append(i.text_content().strip())
  14. titleList = ''.join(titleList)
  15. if len(titleList) >= 3:
  16. print "Title List: "+titleList
  17. string = "URL title: %s" % (''.join(titleList))
  18. say(string)
Add Comment
Please, Sign In to add comment