2016-06-27 3 views
0

私はPythonで初心者ですが、EclipseにPyDevを使用して正常にScrapyをインストールしました。私はそれがこのように表示されるプログラムの開発(図が示す)Scrapy 1.1.0 - アクティブなプロジェクトがありません

[error screenshot]

を実行すると、私はこのコードを実行しています:

import scrapy 

class DmozSpider(scrapy.Spider): 
    name = "dmoz" 
    allowed_domains = ["dmoz.org"] 
    start_urls = [ 
     "http://www.dmoz.org/Computers/Programming/Languages/Python/Books/", 
     "http://www.dmoz.org/Computers/Programming/Languages/Python/Resources/" 
    ] 

    def parse(self, response): 
     for sel in response.xpath('//ul/li'): 
      title = sel.xpath('a/text()').extract() 
      link = sel.xpath('a/@href').extract() 
      desc = sel.xpath('text()').extract() 
      print title, link, desc 

それは何ですか?プログラムを実行できません。

+0

実行しているコマンドは何ですか? –

+0

あなたはその質問を更新できますか? –

+0

完了... – Awais

答えて

2

現在のディレクトリはScrapyプロジェクトではありません。

治療プロジェクトには、定義された形式とファイルがあります。あなたは本当に一度チュートリアルを行う必要があります:http://doc.scrapy.org/en/latest/intro/tutorial.html

基本的には、Scrapyプロジェクトのようにディレクトリ構造を持っている:あなたのプロジェクトフォルダに移動し、実行scrapyプロジェクトを作成するには

tutorial/ 
    scrapy.cfg   # deploy configuration file 

    tutorial/    # project's Python module, you'll import your code from here 
     __init__.py 

     items.py   # project items file 

     pipelines.py  # project pipelines file 

     settings.py  # project settings file 

     spiders/   # a directory where you'll later put your spiders 
      __init__.py 
      ... 

scrapy startproject projectname 

プロジェクトを作成した後、あなたはプロジェクトのルートフォルダからscrapyを実行できるようになりました。あなたがscrapyを実行するときは、プロジェクトのルートにいることを確認してください。

関連する問題