pcpop.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:lichking 作者: melonrun 项目源码 文件源码
def get_changyan_topic_id(self, response):
        article_item = YPcpopItem()
        article_item._id = response.meta['article_id']
        comment_all = json.loads(response.body)
        if 'cmt_sum' in comment_all:
            article_item.replies = str(comment_all['cmt_sum'])
        if 'participation_sum' in comment_all:
            article_item.views = str(comment_all['participation_sum'])
        MongoClient.save_forum_views(article_item, YPcpopItem)
        MongoClient.save_forum_replies(article_item, YPcpopItem)
        if 'topic_id' in comment_all:
            yield scrapy.Request(
                'http://changyan.sohu.com/api/2/topic/comments?&client_id=cyrYYYfxG&page_size=100&page_no=1&topic_id='+
                str(comment_all['topic_id']),
                meta={"article_id": article_item._id, "page_no":1, "topic_id":str(comment_all['topic_id'])},
                callback=self.get_changyan_comment
            )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号