我用scrapy.FormRequest.from_response
来发帖。我正在通过验证码,所有的数据都在适当的地方,但没有得到我期望的表。
这是我的有效载荷
{
'captcha': '680336',
'districtCode': '714',
'sroVal': 'TADIKONDA(714)',
'selectedSroId': 'null',
'sroId': '7',
'path': '/APCARDECClient',
'regyear': '2018',
'docSel': '1',
'doct': '861'
}
以及我用于Post请求的邮件头。在
^{pr2}$当我使用相同的数据来模拟Postman中的Post时,它工作得很好,并且我收到了预期的表。 这是邮递员的有效载荷:
captcha:331683
districtCode:7
docSel:1
doct:861
path:/APCARDECClient
regyear:2018
selectedSroId:null
sroId:714
sroVal:TADIKONDA(714)
还有邮递员的头条:
Origin:http://registration.ap.gov.in
Upgrade-Insecure-Requests:1
DNT:1
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Referer:http://registration.ap.gov.in/APCARDECClient/FetchHelpDetails
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.9,ru;q=0.8,uk;q=0.7
Cookie:JSESSIONID=dQJTbqhpYdg1PMjJZkYT9bTyLLnMqV43zxj2sws1gZ2fQ8fJn0CQ!-392092779
Content-Type:application/x-www-form-urlencoded
请告诉我我哪里错了? 我看到的唯一可能是这条线:
Content-Type:application/x-www-form-urlencoded
我需要在scray中显式地执行smth来对有效负载进行这样的编码吗?在
当我使用裸体
yield scrapy.Request(url, method ="POST", body=json.dumps(payload),headers=headers, callback = self.details1)
不要使用
FormRequest
-它只是注入一些头和一些主体快捷方式。如果要复制请求,只需使用barebonesRequest
。在好吧。所以问题出在
'Content-Type': 'application/x-www-form-urlencoded',
我一开始就注意到了,但没有再多加注意。太蠢了。 为了通过这个页面,有效负载应该是urlencoded
,如Content_Type
所示。 下面是如何做到的。在相关问题 更多 >
编程相关推荐