它只能使用一个用户名加上密码和验证码。
逻辑如下:
def start_requests(self):
yield request(indexUrl, headers=headers, callback=self.downloadPic)
def downloadPic(self, response):
# get cookies from the response and add it to the headers
yield request(picUrl, headers=headers, callback=self.handlePic)
def handlePic(self, response):
# extract text from the picture
# form data include username, password and verification code
yield FormRequest(postUrl, formdata, headers=headers, callback=self.parse)假设我们在本地有很多用户名和密码。我想多次重复这个logoc,只需在formdata中更改用户名和密码即可。
我曾尝试使用for循环来获取每个用户名和密码,然后生成一个新的请求,但它不起作用。
有什么好主意吗?
发布于 2016-06-19 18:54:11
我编写了一个脚本来调用我的爬行器,将表单数据传递给它。而且它起作用了!
https://stackoverflow.com/questions/37904319
复制相似问题