まだまだ改善をしていきますが、自分メモ用的に残します。
サンプルプログラム
オフィシャルドキュメントを参考に、サンプルプログラムを作成した。
★店舗の一覧から店名と電話番号を取得する
(以前よく買い物していたフィットケアデポさんをサンプルとさせていただきました)
depo_spider.py
import scrapy
class DepoSpider(scrapy.Spider):
name = "depo"
start_urls = [
'http://www.kamegaya.co.jp/cgi-bin/cl/public/index.cgi/kmg/search/index'
]
def parse(self, response):
for depo in response.css('div.result'):
yield {
'title': depo.css('h3 a::text').extract_first(),
'tel' : depo.css('li.tel a::text').extract_first()
}
プログラムの実行は以下。
(ググればすぐに見つかるけれど)
scrapy runspider depo_spider.py -o depo.json