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
)
评论列表
文章目录