当前位置:网站首页>scrapy返回400
scrapy返回400
2022-06-26 02:19:00 【0&1菜菜】
- 场景
使用scrapy对数据进行抓取,需要传递的参数是Request Payload参数,使用Resquest发送post请求 - 代码如下
这是返回400的代码
yield scrapy.Request(url=url,
method="POST",
headers={
"Content-Type":"application/json","Host":"web.hi-teeth.com","Content-Length":"18"},
encoding="utf-8",
body=json.dumps({
"key":"value"}),
dont_filter=True,
callback=回调函数)
原因
头部信息中的"Content-Length":"18"造成的错误信息,取消掉就可以,个人任务可能是限制为18造成长度不足的错误解决方案
去掉头部信息中的"Content-Length"即可
正确代码
yield scrapy.Request(url=url,
method="POST",
headers={
"Content-Type":"application/json","Host":"web.hi-teeth.com"},
encoding="utf-8",
body=json.dumps({
"key":"value"}),
dont_filter=True,
callback=回调函数)
有知道正确原因的同学可以指导一下,万分感谢
边栏推荐
- A few simple ways for programmers to exercise their waist
- How to prompt
- Blazor University (33) form - editcontext, fieldidentifiers
- Multi surveyor Gongshu Xiao sir_ The solution of using websocket error reporting under working directory
- What is the sudden power failure of iPhone and how to solve it?
- Dreamcamera2 video recording, playing without sound, recording function is normal, using a third-party application for video recording, playing with sound
- 多测师拱墅校区肖sir_jenkins中搭建出现页面报错
- What is flush software? Is online account opening safe?
- Gd32 ADC acquisition voltage
- 多测师拱墅肖sir_工作目录下的use websocket报错解决方案
猜你喜欢
Fresh graduates talk about their graduation stories
df报错Stale file handle
Overview of orb-slam3 paper
2022-06-25:给定一个正数n, 表示有0~n-1号任务, 给定一个长度为n的数组time,time[i]表示i号任务做完的时间, 给定一个二维数组matrix, matrix[j] = {a,
分享一些在内网操作的远程办公经验| 社区征文
【flask入门系列】flask处理请求和处理响应
Depth first traversal of Graphs
第一章:渗透测试的本质信息收集
MySQL must master 4 languages!
The programmer's eight-year salary change has made netizens envious: you pay me one year's salary per month
随机推荐
股票开户怎么开户?网上开户是否安全么?
音视频与CPU架构
Cow sequencing problem
What is the sudden power failure of iPhone and how to solve it?
df报错Stale file handle
如何在 ggplot2 中删除网格线(附示例)
OpenAPI 3.0 specification - Food Guide
DF reports an error stale file handle
[solution] the blue screen restart problem of the virtual machine started by the VMware of Lenovo Savior
版本管理工具使用
[defect detection] automatic defect detection of printed circuit board based on Matlab GUI [including Matlab source code 1912]
如何提词条
vulhub复现一 activemq
Share some remote office experience in Intranet operation | community essay solicitation
Cox 回归模型
Create a nonlinear least squares test in R
Arthas(阿尔萨斯) 能为你做什么?
Is it safe to trade stocks with a compass? How does the compass trade stocks? Do you need to open an account
Win10 computer power management turns on excellence mode
I am in Zhongshan. Where can I open an account? Is it safe to open an account online?