質問

フレームワークScrapy - Scrapydサーバ。

クモの中のjobid値を取得することに問題があります。

http:// localhost:6800 / schedule.json 応答は

status = ok
jobid = bc2096406b3011e1a2d0005056c00008
.

しかし、このプロセス中に現在のクモの中にこのjobidを使用する必要があります。Open {jobid} .logファイルまたは他の動的な理由から使用できます。

class SomeSpider(BaseSpider):
    name = "some"
    start_urls = ["http://www.example.com/"]
    def parse(self, response):
        items = []
        for val in values:
            item = SomeItem()
            item['jobid'] = self.jobid # ???!
            items.append(item)
        return items
.

しかし、私はこのjobidがあなたがFineihedの後にのみ見えます:(ありがとう!

役に立ちましたか?

解決

I guess there is an easier way, but you can extract job id from command line args. IIRC, scrapyd launches a spider giving it a jobid in parameters. Just explore sys.args where you need jobid.

他のヒント

You can get it from the SCRAPY_JOB environment variable:

os.environ['SCRAPY_JOB']
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top