Skip to content

Commit

Permalink
write result to file.
Browse files Browse the repository at this point in the history
  • Loading branch information
kakashitheaf committed Jun 13, 2016
1 parent 336fac8 commit 4fa2d68
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
6 changes: 4 additions & 2 deletions douyu/douyu/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@

class douyuItem(Item):
# define the fields for your item here like:
name = Field()

url = Field()
room_name = Field()
people_count = Field()
tag = Field()
24 changes: 19 additions & 5 deletions douyu/douyu/spiders/spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,27 @@ class douyuSpider(CommonSpider):
'room_name': 'a::attr(title)',
'tag': 'span.tag.ellipsis::text',
'people_count': '.dy-num.fr::text'
}
}
}
}

list_css_rules_for_item = {
'#live-list-contentbox li': {
'__use': '1',
'__list': '1',
'url': 'a::attr(href)',
'room_name': 'a::attr(title)',
'tag': 'span.tag.ellipsis::text',
'people_count': '.dy-num.fr::text'
}
}


def parse_1(self, response):
info('Parse '+response.url)
x = self.parse_with_rules(response, self.list_css_rules, dict)
print(json.dumps(x, ensure_ascii=False, indent=2))
#x = self.parse_with_rules(response, self.list_css_rules, dict)
x = self.parse_with_rules(response, self.list_css_rules_for_item, douyuItem)
print(len(x))
# print(json.dumps(x, ensure_ascii=False, indent=2))
# pp.pprint(x)
# return self.parse_with_rules(response, self.css_rules, douyuItem)
# return self.parse_with_rules(response, self.list_css_rules, douyuItem)
return x

0 comments on commit 4fa2d68

Please sign in to comment.