0
我閱讀文檔並找到命令行應該是這樣的。 scrapy runspider getspecificimg.py -a ip='lizhe'
如何使用-a選項將參數傳遞給scrapy?
我的蜘蛛的代碼是這樣的:
class GetImage(scrapy.Spider):
name = 'ImageSpider'
start_urls = ['https://www.pexels.com/']
# Get the input argument
# NameNeedSearch = InputPara
NameNeedSearch = ip
但結果我得到的意思是ip isn't defined why?
20161211162649.bmp
- 更新 - 我想在一個變量來傳遞,然後使用它來連接full url
並將其用作start_url
我的代碼如下所示:並獲取錯誤self is not defined
爲什麼?
class GetImage(scrapy.Spider):
name = 'ImageSpider'
# Get the input argument
NameNeedSearch = self.ip
# startUrl = 'https://www.pexels.com/' +
start_urls = ['https://www.pexels.com/']