scrapy Post 发送数据是我们通常会用来发送请求
yield scrapy.FormRequest(
url = url,
formdata = {"email" : "xxx", "password" : "xxxxx"},
callback = self.parse_page
)
但这是发送header为 ‘Content-Type‘, ‘application/x-www-form-urlencoded‘ 的数据,
有时候我们做一些爬虫,会post发送json数据,否则不能返回正确的结果,如果直接用request很方便,
但在scrapy里就需要这样用
form_data = { "limit":"5", "start":"0", "type":"1", "url":"http://118.114.241.241:8829/BASE_SCKJ/biddingInfo.do?baseUrl=10.192.6.229:8080/netWorkToData/getProjectMessageByTypeSupplierCode" } yield scrapy.Request( url=‘http://139.9.60.172:8071/api/transmit/to‘, method="POST", headers={‘Content-Type‘: ‘application/json‘}, body=json.dumps(form_data), meta={"type":my.notice}, callback=self.parse, errback=self.errorback, dont_filter=True)
这样就可以发送json 数据了