Mercurial > eagle-eye
diff pyikriam/lazy/www/work/find.py @ 62:a4c364888197
add ikriam game binding lib python version
author | hychen@mluna |
---|---|
date | Wed, 22 Oct 2008 04:04:32 +0800 |
parents | |
children | 60c4b4b78a01 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pyikriam/lazy/www/work/find.py Wed Oct 22 04:04:32 2008 +0800 @@ -0,0 +1,23 @@ +from lxml import etree +from cStringIO import StringIO + +class Finder: + + dom_tree = None + xpath = None + + def __init__(self, working_product): + self.working_prodcut = working_product + + self.encoding = 'utf8' + parser = etree.HTMLParser(encoding=self.encoding) + self.dom_tree = etree.parse(StringIO(self.working_prodcut.content), parser) + + def find(self, express , callback = None): + xpath = self.dom_tree.xpath(express) + + if callback is None: + ret = xpath + else: + ret = self.callback(xpath) + return ret