summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Ruby <rubys@intertwingly.net>2011-02-11 12:01:02 -0500
committerSam Ruby <rubys@intertwingly.net>2011-02-11 12:01:02 -0500
commitc88afaacb06cf477c68100018e3e730318558522 (patch)
tree857c6e580d39443f60d4d20bea20f2fe2775d220
parent6481eaf5a816533489a775aa83974a0b65b506c8 (diff)
downloadplanetpixels-c88afaacb06cf477c68100018e3e730318558522.tar.gz
planetpixels-c88afaacb06cf477c68100018e3e730318558522.tar.bz2
Case insensitive rel values; ensure linked icon exists
-rw-r--r--favicon.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/favicon.py b/favicon.py
index ad9f5d2..2e351a3 100644
--- a/favicon.py
+++ b/favicon.py
@@ -32,11 +32,11 @@ for sub in config.subscriptions():
def favicon(page):
parser=html5parser.HTMLParser(tree=treebuilders.getTreeBuilder('dom'))
doc=parser.parse(urlopen(page))
+ favicon = urljoin(page, '/favicon.ico')
for link in doc.getElementsByTagName('link'):
if link.hasAttribute('rel') and link.hasAttribute('href'):
- if 'icon' in link.attributes['rel'].value.split(' '):
- return urljoin(page, link.attributes['href'].value)
- favicon = urljoin(page, '/favicon.ico')
+ if 'icon' in link.attributes['rel'].value.lower().split(' '):
+ favicon = urljoin(page, link.attributes['href'].value)
if urlopen(favicon).info()['content-length'] != '0':
return favicon