在scrapyrt的POST文档中,我们可以像这样传递JSON请求,但是如何访问start_requests中的category和item之类的 meta数据呢?
{
"request": {
"meta": {
"category": "some category",
"item": {
"discovery_item_id": "999"
}
},
, "start_requests": true
},
"spider_name": "target.com_products"
}
参考:https://scrapyrt.readthedocs.io/en/latest/api.html#id1
1条答案
按热度按时间9rygscc11#
在scrapyRT中有一个未合并的PR,它增加了对在POST请求中传递额外参数的支持。
1)补丁resources.py文件位于scrapyrt文件夹。在我的例子中是/usr/local/lib/python3.5/dist-packages/scrapyrt/resources.py
替换为以下代码:https://github.com/gdelfresno/scrapyrt/commit/ee3be051ea647358a6bb297632d1ea277a6c02f8
2)现在,spider可以使用self.param1访问新参数
ScrapyRT curl 示例:
在你的蜘蛛
此致