from scrapy.http import Request,FormRequest
def start_requests(self): return [Request('http://www.com/login.htm', meta={'cookiejar': 1}, callback=self.parse)] def parse(self, response): url = 'http://www.com/login.htm' data = { #这里放data数据 } yield FormRequest.from_response(response, url=url, # 真实post地址 meta={'cookiejar': response.meta['cookiejar']}, formdata=data, callback=self.next ) def next(self,response): cookie = response.request.headers.getlist('Cookie')[0].decode() self.cookie = dict([l.split("=", 1) for l in cookie.split("; ")]) url = "http://www.com/index.htm" yield scrapy.Request(url=url,cookies=self.cookie,callback=self.get_parse,dont_filter=True)