如何使用SCRAPY向API发出POST请求

2024-06-06 14:57:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我想知道使用SCRAPYAPI发出POST请求的方法

如果你认为这个问题不符合标准,请容忍我

谢谢你的帮助

我正在抓取一个用API显示数据的网站,但不幸的是,我无法抓取它

网站:https://www.sla.org.sg/hive/sla/membershipDirectory

enter image description here


Tags: 数据方法httpsorgapi网站wwwsg
1条回答
网友
1楼 · 发布于 2024-06-06 14:57:06

您需要生成一个FormRequest,请求主体应该进入formdata参数Read more here. 大概是这样的:

api_url =  'https://www.sla.org.sg/hive/sla/membershipDirectory/search'
sample_form = {
   'field1': 'value1',
   'field2': 'value2',
}
yield FormRequest(url=api_url, formdata=sample_form, callback=your_parsing_method)

相关问题 更多 >