[title] Try to fix with certain sites
parent
382e7cb15b
commit
8a432e905c
10
title.py
10
title.py
|
@ -23,16 +23,14 @@ def title(phenny, input):
|
||||||
data, sc = web.get(uri, 16384)
|
data, sc = web.get(uri, 16384)
|
||||||
if sc != 200:
|
if sc != 200:
|
||||||
return phenny.say("HTTP error %d" % sc)
|
return phenny.say("HTTP error %d" % sc)
|
||||||
try:
|
|
||||||
data = str(data, 'utf-8')
|
data = str(data, 'utf-8', 'ignore')
|
||||||
except UnicodeDecodeError:
|
|
||||||
return phenny.say("Doesn't seem to be HTML..")
|
|
||||||
m = re.search(r_title, data)
|
m = re.search(r_title, data)
|
||||||
if not m:
|
if not m:
|
||||||
return phenny.say("No title found.")
|
return phenny.say("No title found.")
|
||||||
title = m.group(1)
|
title = m.group(1)
|
||||||
title = html.unescape(title)
|
title = html.unescape(title).strip()
|
||||||
title = title.strip()
|
|
||||||
if len(title) > 150:
|
if len(title) > 150:
|
||||||
title = title[:150] + "[...]"
|
title = title[:150] + "[...]"
|
||||||
phenny.reply(title)
|
phenny.reply(title)
|
||||||
|
|
Loading…
Reference in New Issue