diff pyikriam/__init__.py @ 162:e49137521123

pyikriam retrive information about land positions. - It retrive type of building on positions.
author Thinker K.F. Li <thinker@branda.to>
date Sun, 02 Nov 2008 00:12:53 +0800
parents 1507c2d16b35
children f7fd2738b9b4
line wrap: on
line diff
--- a/pyikriam/__init__.py	Sat Nov 01 22:21:25 2008 +0800
+++ b/pyikriam/__init__.py	Sun Nov 02 00:12:53 2008 +0800
@@ -85,15 +85,20 @@
         from lxml import etree
         from StringIO import StringIO
 
-	print "pull datas of the city %s" % self.id
-        xpath_globalinfo = "/html/body[@id='city']/div[@id='container']/div[@id='container2']"
-
         page = c(self.core.baseurl).get(self.params).get_content()
         parser = etree.HTMLParser(encoding='utf8')
         page_dom = etree.parse(StringIO(page), parser)
+
+        xpath_globalinfo = "/html/body[@id='city']/div[@id='container']/div[@id='container2']"
         for name, path in self.data_patterns.items():
             xpath = xpath_globalinfo + path
             value = page_dom.xpath(xpath)[0]
             setattr(self, name, value)
+            pass
+        
+        xpath_mainview = '/html/body/div/div/div[@id=\'mainview\']/ul/li'
+        pos_doms = page_dom.xpath(xpath_mainview)
+        positions = [pos_dom.get('class').split()[-1] for pos_dom in pos_doms]
+        self.positions = positions
         pass
     pass