Mercurial > eagle-eye
comparison 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 |
comparison
equal
deleted
inserted
replaced
161:1507c2d16b35 | 162:e49137521123 |
---|---|
83 | 83 |
84 def sync(self): | 84 def sync(self): |
85 from lxml import etree | 85 from lxml import etree |
86 from StringIO import StringIO | 86 from StringIO import StringIO |
87 | 87 |
88 print "pull datas of the city %s" % self.id | |
89 xpath_globalinfo = "/html/body[@id='city']/div[@id='container']/div[@id='container2']" | |
90 | |
91 page = c(self.core.baseurl).get(self.params).get_content() | 88 page = c(self.core.baseurl).get(self.params).get_content() |
92 parser = etree.HTMLParser(encoding='utf8') | 89 parser = etree.HTMLParser(encoding='utf8') |
93 page_dom = etree.parse(StringIO(page), parser) | 90 page_dom = etree.parse(StringIO(page), parser) |
91 | |
92 xpath_globalinfo = "/html/body[@id='city']/div[@id='container']/div[@id='container2']" | |
94 for name, path in self.data_patterns.items(): | 93 for name, path in self.data_patterns.items(): |
95 xpath = xpath_globalinfo + path | 94 xpath = xpath_globalinfo + path |
96 value = page_dom.xpath(xpath)[0] | 95 value = page_dom.xpath(xpath)[0] |
97 setattr(self, name, value) | 96 setattr(self, name, value) |
97 pass | |
98 | |
99 xpath_mainview = '/html/body/div/div/div[@id=\'mainview\']/ul/li' | |
100 pos_doms = page_dom.xpath(xpath_mainview) | |
101 positions = [pos_dom.get('class').split()[-1] for pos_dom in pos_doms] | |
102 self.positions = positions | |
98 pass | 103 pass |
99 pass | 104 pass |