一 问题描述
用scrapy.Request()方法请求一个url地址,发现返回400错误,我检查了我不是被封ip,把请求链接直接copy到浏览器上,是可以正常显示结果的,单独用python的requests模块post请求同样的url地址,获得的是正常的返回,我就不明白了,是我scrapy.Request的里面格式错误了?
二 代码展示
scrapy的 spider文件,scrapy项目是用scrapy的命令行执行出来的,常规设置,其他不变
# -*- coding: utf-8 -*-
import scrapy
class PileSpider(scrapy.Spider):
name = "pile"
allowed_domains = ["www.evehicle.cn"]
headers = {
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.8',
'Connection': 'keep-alive',
'Content-Length': '11',
'Content-Type': 'application/x-www-form-urlencoded; charset=UT