2017-09-11 14 views
1

設定モジュールのenvvar値をmy_module.my_submodule.my_leaf_moduleに設定しました。内部には、DEFAULT_REQUEST_HEADERS辞書を含む多くの定数が設定されています。とにかく私は上記のように設定し、スパイダーを指定せずに必要なサンプルURLに対してscrapyシェルを実行します。起動時に例外や警告はありませんが、私の提供された設定モジュールは使用されていません。SCRAPY_SETTINGS_MODULEを無視しているスキルシェル

私は間違っていますか?

答えて

3

シェルの間に設定モジュールが読み込まれていないと思います。それはそれの言及を持っていない

https://doc.scrapy.org/en/latest/topics/shell.html

以下のドキュメントを参照してください。ただし、DebugSpiderを作成し、そこにあなたのURLを立ち上げてデバッグシェルを起動することができます。だから、

これはまたあなたの設定モジュールをロードし、要求を作成し、あなたに

2017-09-12 00:16:27 [scrapy.core.engine] DEBUG: Crawled (200) <GET http://tarunlalwani.com> (referer: None) 
[s] Available Scrapy objects: 
>>> [s] scrapy  scrapy module (contains scrapy.Request, scrapy.Selector, etc) 
[s] crawler <scrapy.crawler.Crawler object at 0x10562b748> 
[s] item  {} 
[s] request <GET http://tarunlalwani.com> 
[s] response <200 http://tarunlalwani.com> 
[s] settings <scrapy.settings.Settings object at 0x106432c50> 
[s] Useful shortcuts: 
[s] shelp()   Shell help (print this help) 
[s] view(response) View response in a browser 
を同じデバッグシェルを与える、端末の実行から次に
class DebugSpider(scrapy.Spider): 
    name = "debug" 

    def __init__(self, url=None): 
     if url is None: 
      raise Exception("Please specify a url using -a url=....") 
     self.start_urls = [url] 

    def parse(self, response): 
     from scrapy.shell import inspect_response 
     inspect_response(response, self) 

あなたのクモのコードに以下の

scrapy crawl debug -a url="http://tarunlalwani.com" 

を追加します

関連する問題