# Path: crawler/gather/items.py
# class ChannelItem(Item):
#     office_id = Field()
#     short = Field()
#     name = Field()
#     image = Field()
#     url = Field()
# 
# class RoomItem(Item):
#     office_id = Field()
#     name = Field()
#     image = Field()
#     url = Field()
#     online = Field()
#     host = Field()
#     channel = Field()
#     followers = Field()
#     description = Field()
#     announcement = Field()
#     start_time = Field()


from scrapy import Spider, Request
from datetime import datetime
from ..items import ChannelItem, RoomItem
import json
                yield Request(url, callback=self.parse_collection)
            else:
                short = url[url.rfind('/') + 1:]
                name = a_element.xpath('p/text()').extract_first()
                yield ChannelItem({
                    'short': short,
                    'name': name,
                    'image': image,
                    'url': url
                })
                url = 'https://www.huomao.com/channels/channel.json?page_size=120&game_url_rule={}'.format(short)
                yield Request('{}&page=1'.format(url), callback=self.parse_room_list, meta={'url': url, 'page': 1})

    def parse_collection(self, response):
        for a_element in response.xpath('//div[@id="game_label"]/li/a')[1:]:
            short = a_element.xpath('@id').extract_first()
            yield ChannelItem({
                'short': short,
                'name': a_element.xpath('text()').extract_first(),
                'url': response.urljoin('/channel/{}'.format(short))
            })
            url = 'https://www.huomao.com/channels/channel.json?page_size=120&game_url_rule={}'.format(short)
            yield Request('{}&page=1'.format(url), callback=self.parse_room_list, meta={'url': url, 'page': 1})

    def parse_room_list(self, response):
        room_list = json.loads(response.text)['data'].get('channelList', None)
        if isinstance(room_list, list):
            for rjson in room_list:
                if int(rjson['is_live']) == 0:
                    break

# Path: crawler/gather/items.py
# class ChannelItem(Item):
#     office_id = Field()
#     short = Field()
#     name = Field()
#     image = Field()
#     url = Field()
# 
# class RoomItem(Item):
#     office_id = Field()
#     name = Field()
#     image = Field()
#     url = Field()
#     online = Field()
#     host = Field()
#     channel = Field()
#     followers = Field()
#     description = Field()
#     announcement = Field()
#     start_time = Field()


# Path: crawler/gather/spiders/huomao.py
from scrapy import Spider, Request
from datetime import datetime
from ..items import ChannelItem, RoomItem
import json

                yield Request(url, callback=self.parse_collection)
            else:
                short = url[url.rfind('/') + 1:]
                name = a_element.xpath('p/text()').extract_first()
                yield ChannelItem({
                    'short': short,
                    'name': name,
                    'image': image,
                    'url': url
                })
                url = 'https://www.huomao.com/channels/channel.json?page_size=120&game_url_rule={}'.format(short)
                yield Request('{}&page=1'.format(url), callback=self.parse_room_list, meta={'url': url, 'page': 1})

    def parse_collection(self, response):
        for a_element in response.xpath('//div[@id="game_label"]/li/a')[1:]:
            short = a_element.xpath('@id').extract_first()
            yield ChannelItem({
                'short': short,
                'name': a_element.xpath('text()').extract_first(),
                'url': response.urljoin('/channel/{}'.format(short))
            })
            url = 'https://www.huomao.com/channels/channel.json?page_size=120&game_url_rule={}'.format(short)
            yield Request('{}&page=1'.format(url), callback=self.parse_room_list, meta={'url': url, 'page': 1})

    def parse_room_list(self, response):
        room_list = json.loads(response.text)['data'].get('channelList', None)
        if isinstance(room_list, list):
            for rjson in room_list:
                if int(rjson['is_live']) == 0:
                    break

                item = RoomItem({