Permalink
Browse files

Improve iconInPage, deleteAll now clears memcache too

git-svn-id: https://potato.codebasehq.com/getfavicon/getfavicon.svn/trunk@23 0c1c7bd3-9391-4859-b94e-4e2dcdc6a516
  • Loading branch information...
1 parent 42ffeb1 commit e0113e613ddab520919da8eb5e23a3d17de03270 jason committed Aug 29, 2010
Showing with 20 additions and 8 deletions.
  1. +20 −8 main.py
View
28 main.py
@@ -45,7 +45,11 @@ def headlessDenial(self):
class deleteAll(BaseHandler):
def get(self):
+
if self.isDev():
+
+ memcache.flush_all()
+
allfavIconQuery = favIcon.all()
favIcons = allfavIconQuery.fetch(500)
db.delete(favIcons)
@@ -202,7 +206,7 @@ def iconAtRoot(self):
rootDomainFaviconResult = urlfetch.fetch(
url = rootIconPath,
- follow_redirects = False,
+ follow_redirects = True,
)
except:
@@ -257,17 +261,25 @@ def iconInPage(self):
try:
pageSoup = BeautifulSoup.BeautifulSoup(rootDomainPageResult.content)
- pageSoupIcon = pageSoup.findAll("link",rel=re.compile("shortcut|icon|shortcut icon",re.IGNORECASE))
+ pageSoupIcon = pageSoup.find("link",rel=re.compile("^(shortcut|icon|shortcut icon)$",re.IGNORECASE))
except:
self.writeDefault()
return False
-
-
- if len(pageSoupIcon) > 0:
-
- pageIconPath = urljoin(self.targetPath,pageSoupIcon[0]["href"])
+
+ if pageSoupIcon:
+
+ pageIconHref = pageSoupIcon.get("href")
+
+ if pageIconHref:
+
+ pageIconPath = urljoin(self.targetPath,pageIconHref)
+
+ else:
+
+ inf("No icon found in page")
+ return False
inf("Found unconfirmed iconInPage at %s" % pageIconPath)
@@ -360,7 +372,7 @@ def writeDefault(self, fromCache = False):
def get(self):
-
+
counter.ChangeCount("favIconsServed",1)
# Get page path

0 comments on commit e0113e6

Please sign in to comment.