import scrapy import json class TransferpostSpider(scrapy.Spider): name = 'transferPost' allowed_domains = ['fanyi.baidu.com'] # start_urls = ['http://fanyi.baidu.com/'] # post请求不能用默认生成的,因为不能携带请求参数 # def parse(self, response): # pass def start_requests(self): url = 'https://fanyi.baidu.com/sug' data = { 'kw':'final' } yield scrapy.FormRequest(url=url,formdata=data,callback=self.second_parse) def second_parse(self,response): content = response.text res = json.loads(content,encoding='utf-8') print(res)
标签:baidu,self,练习,parse,scrapy,post,response From: https://www.cnblogs.com/sgj191024/p/17743480.html