私はドキュメントを読んで、コマンドラインがこのようになっていることを確認します。 scrapy runspider getspecificimg.py -a ip='lizhe'
パラメータをscrapyに渡す-aオプションの使い方は?
そして、私のクモのコードは次のようである:
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/']