class Player(Item): id = IntegerField('//player/@id') first_name = StringField('//player/firstname') retrieved = DateTimeField('//player/@retrieved', '%Y-%m-%dT%H:%M:%SZ') comment = StringField('//player/comment') comment_cdata = StringField('//player/comment_cdata') data_not_found = StringField('//data/no/found') @func_field(pass_item=True) def calculated(item, sel): if not hasattr(item, 'count'): item.count = 1 else: item.count += 1 return sel.select('//height').text() + '-zoo-' + str(item.count) calculated2 = FuncField(calculated_func2, pass_item=True)
class GameItem(Item): class Meta: find_query = '//games/game' name = StringField('@name')
class PlanetItem(Item): class Meta: find_query = '$..planets[*]' selector_type = 'json' name = StringField('name')
class GameItem(Item): class Meta: find_query = '//games/game' name = StringField('@name') names = StringField('@name', multiple=True)
class ChildItem(BaseItem): name = StringField('lastname')
class BaseItem(Item): class Meta: find_query = '//player' name = StringField('firstname') age = IntegerField('age')
class GameItem(Item): names = StringField('//game/@name', multiple=True)