from scrapy.http import FormRequest #replace the start_urls statement with a start_requests() method def start_requests(self): return [ FormRequest( "http://web:9312/dynamic/login", formdata={"user": "user", "pass": "pass"}
确认启用了Cookie
# Start on the welcome page def start_requests(self): return [ Request( "http://web:9312/dynamic/nonce", callback=self.parse_welcome) ] # Post welcome page‘s first form with the given user/pass def parse_welcome(self, response): return FormRequest.from_response( response, formdata={"user": "user", "pass": "pass"}