diff pyikriam/buildings.py @ 175:9f248c8460ce

Simplize xpath patterns. - Use 'descendant' aix name simplize patterns.
author Thinker K.F. Li <thinker@branda.to>
date Sun, 02 Nov 2008 09:59:51 +0800
parents 8f699a9da6c0
children 3ba3edda6d1e
line wrap: on
line diff
--- a/pyikriam/buildings.py	Sun Nov 02 04:12:23 2008 +0800
+++ b/pyikriam/buildings.py	Sun Nov 02 09:59:51 2008 +0800
@@ -20,7 +20,7 @@
 
 class townhall(position):
     xpath_patterns = {
-        'level': '/div/div/div[@class=\'buildingLevel\']/text()'
+        'level': 'div[@class=\'buildingLevel\']/text()'
         }
 
     def __init__(self, city_id, idx, baseurl):
@@ -30,7 +30,7 @@
     def _sync(self, page):
         parser = etree.HTMLParser(encoding='utf8')
         page_dom = etree.parse(StringIO(page), parser)
-        xpath_building = '/html/body/div/div'
+        xpath_building = '/html/body/descendant::'
         for name, ptn in self.xpath_patterns.items():
             path = xpath_building + ptn
             value = page_dom.xpath(path)[0]