如何在命令行上传递scrapy shell中的表单数据

Pra*_*eep 3 scrapy python-2.7 scrapy-spider

我从命令行使用scrapy shell并使用scrapy shell"abcwebsitexyz.com"来测试我的一些代码及其值,但我想用它传递表单数据.就像我在下面试过的那样

scrapy shell "abcwebsitexyz.com", formdata={'username': 'user_name','password':'password',}
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

请帮忙.

eLR*_*uLL 9

您可以直接使用shell,然后将表单传递给请求:

$ scrapy shell
Run Code Online (Sandbox Code Playgroud)

并在shell内:

>> from scrapy import FormRequest
>> fetch(FormRequest('http://abcwebsitexyz.com', formdata={'username': 'user_name','password':'password',}))
Run Code Online (Sandbox Code Playgroud)

as fetch使用当前请求更新shell会话.