标签 python 下的文章

在Pipelines中新建以下类

class PostApiPipeline(object):
    async def process_item(self, item, spider):
        request=scrapy.Request("xxxx/api.php", method="POST", body=json.dumps(dict(item)), headers={'Content-Type': 'application/json'})
        response = await spider.crawler.engine.download(request, spider)
        return item