blog/content/post/2009/09/04/2009-09-04-00001218.md

13 KiB
Raw Blame History

title author date url wordtwit_post_info categories
スターバックスの店舗情報をスクレイピング kazu634 2009-09-04 /2009/09/04/_1323/
O:8:"stdClass":13:{s:6:"manual";b:0;s:11:"tweet_times";i:1;s:5:"delay";i:0;s:7:"enabled";i:1;s:10:"separation";s:2:"60";s:7:"version";s:3:"3.7";s:14:"tweet_template";b:0;s:6:"status";i:2;s:6:"result";a:0:{}s:13:"tweet_counter";i:2;s:13:"tweet_log_ids";a:1:{i:0;i:4767;}s:9:"hash_tags";a:0:{}s:8:"accounts";a:1:{i:0;s:7:"kazu634";}}
Perl
scraper

前から細々とやっていましたが、だいぶ慣れてきたので本格的に取り組みます。

とりあえずここに書き散らかしておきますね。

リンクの取得

スターバックス コーヒー | 店舗検索からリンクを取得します。このXPathなら簡単なはず

#!/usr/bin/perl
use strict;
use Web::Scraper;
use URI;
my $uri = URI->new("http://www.starbucks.co.jp/search/index.html/");
my $scraper = scraper {
process '//area[@shape="RECT"]', 'prefs[]' => '@href';
process '//td[@class="SelectFromPlace"]//a', 'citys[]' => '@href';
};
my $result = $scraper->scrape($uri);

実行結果

kazu634@srv634% perl 20090904225211_starbucks.pl                       ~/work/tmp_perl/scrap [4861]
---
citys:
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/tokyo.php
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/kanagawa.php
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/osaka.php
prefs:
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%8C%97%E6%B5%B7%E9%81%93
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E9%9D%92%E6%A3%AE%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%B2%A9%E6%89%8B%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%AE%AE%E5%9F%8E%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E7%A7%8B%E7%94%B0%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%B1%B1%E5%BD%A2%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E7%A6%8F%E5%B3%B6%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E8%8C%A8%E5%9F%8E%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E6%A0%83%E6%9C%A8%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E7%BE%A4%E9%A6%AC%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%9F%BC%E7%8E%89%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%8D%83%E8%91%89%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/tokyo.php
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/kanagawa.php
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%B1%B1%E6%A2%A8%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E9%95%B7%E9%87%8E%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E6%96%B0%E6%BD%9F%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%AF%8C%E5%B1%B1%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E7%9F%B3%E5%B7%9D%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E7%A6%8F%E4%BA%95%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E6%BB%8B%E8%B3%80%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E4%BA%AC%E9%83%BD%E5%BA%9C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/osaka.php
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%85%B5%E5%BA%AB%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%92%8C%E6%AD%8C%E5%B1%B1%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%A5%88%E8%89%AF%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E9%B3%A5%E5%8F%96%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%B3%B6%E6%A0%B9%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%B2%A1%E5%B1%B1%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%BA%83%E5%B3%B6%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%B1%B1%E5%8F%A3%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E7%A6%8F%E5%B2%A1%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E4%BD%90%E8%B3%80%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E9%95%B7%E5%B4%8E%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E7%86%8A%E6%9C%AC%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%A4%A7%E5%88%86%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%AE%AE%E5%B4%8E%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E9%B9%BF%E5%85%90%E5%B3%B6%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E6%B2%96%E7%B8%84%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%BE%B3%E5%B3%B6%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E9%A6%99%E5%B7%9D%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E6%84%9B%E5%AA%9B%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E9%AB%98%E7%9F%A5%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E9%9D%99%E5%B2%A1%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E6%84%9B%E7%9F%A5%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E5%B2%90%E9%98%9C%E7%9C%8C
- !!perl/scalar:URI::http http://www.starbucks.co.jp/search/result_city2.php?SearchPerfecture=%E4%B8%89%E9%87%8D%E7%9C%8C

「スタバ」に関連する最近のエントリ