Scrapy重复提交表格

时间:2016-06-19 05:44:24

标签: python scrapy

它只能使用一个用户名加密码和验证码。

这是逻辑:

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循环来获取每个用户名和密码,然后产生一个新请求,但它不起作用。

所有想法?

1 个答案:

答案 0 :(得分:-1)

我编写了一个脚本来调用我的蜘蛛,将表单数据传递给它。它有效!