import webquery
from lxml import etree


class Parser(object):
    def parse(self, url):
        content = webquery.urlcontent(url)
        root = etree.HTML(content, base_url=url)
        data = {name: expr.parse(root) for name, expr in self.fields.items()}
        data['url'] = url
        return data

@@ -36,31 +36,466 @@
 ree%0A
-%0A%0Aclass Parser(object):
+import inspect%0Afrom expression import Expression%0Afrom collections import defaultdict%0A%0A%0Aclass Parser(object):%0A    registry = defaultdict(dict)%0A%0A    @classmethod%0A    def __init_subclass__(cls):%0A        for name, member in inspect.getmembers(cls):%0A            if isinstance(member, Expression):%0A                cls.registry%5Bcls.__name__%5D%5Bname%5D = member%0A%0A    @property%0A    def fields(self):%0A        cls = self.__class__%0A        return cls.registry%5Bcls.__name__%5D%0A
 %0A   

create fields automatically from class properties