blog/content/post/2009/09/14/2009-09-14-00001221.md

190 lines
22 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: フィルターの概念を覚えた
author: kazu634
date: 2009-09-14
url: /2009/09/14/_1327/
wordtwit_post_info:
- '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:4779;}s:9:"hash_tags";a:0:{}s:8:"accounts";a:1:{i:0;s:7:"kazu634";}}'
categories:
- Perl
---
<div class="section">
<p>
Web::Scraperにはフィルターというものがあります。要はスクレイピングした結果を anonymous subroutine に渡して、結果を操作できてしまう…というものです。
</p>
<h4>
なんでそんなのが必要なの?
</h4>
<p>
Starbucksの店舗情報をスクレイピングしていて、HTMLの文字コードはShift-JISでした。そして、リンクへのURLには日本語が付加されていました。
</p>
<p>
ここでWeb::Scraperを用いてURLを取り込むと、私の環境ではUTF-8でエンコードされたURLが取得され、そのURLでアクセスしてもリンク先へ飛ぶことが出来ませんでした。UTF-8で取り込まれてしまったエンコード済みURLをデコードし、Shift-JISに変換し、再度エンコードするという処理が必要だということがわかりました。
</p>
<h4>
ソース
</h4>
<p>
実際にやってみます:
</p>
<pre class="syntax-highlight">
<span class="synStatement">use strict</span>;
<span class="synStatement">use </span>Web::Scraper;
<span class="synStatement">use </span>URI;
<span class="synStatement">use </span>URI::Escape;
<span class="synStatement">use utf8</span>;
<span class="synStatement">use </span>YAML;
<span class="synStatement">use </span>Perl6::Say;
<span class="synStatement">use </span>Encode;
<span class="synComment"># =================</span>
<span class="synComment"># === Main Part ===</span>
<span class="synComment"># =================</span>
<span class="synComment"># =========================</span>
<span class="synComment"># === 各県へのURLを取得 ===</span>
<span class="synComment"># =========================</span>
<span class="synComment"># starbucksのURLを指定</span>
<span class="synStatement">my</span> <span class="synIdentifier">$uri</span> = URI-&#62;<span class="synStatement">new</span>(<span class="synConstant">&#34;http://www.starbucks.co.jp/search/index.html&#34;</span>);
<span class="synComment"># スクレイピングの設定を行う</span>
<span class="synStatement">my</span> <span class="synIdentifier">$scraper</span> = scraper {
process <span class="synConstant">'//area[@href=~/.+SearchPerfecture/]'</span>, <span class="synConstant">'prefs[]'</span> =&#62; [
<span class="synConstant">'@href'</span>,
<span class="synIdentifier"> </span><span class="synStatement">sub</span><span class="synIdentifier"> </span>{
<span class="synStatement">my</span> <span class="synIdentifier">$url</span> = <span class="synIdentifier">$_</span>-&#62;as_string;
<span class="synStatement">my</span> <span class="synIdentifier">@url_split</span> = <span class="synStatement">split</span>( /=/, <span class="synIdentifier">$url</span> );
<span class="synComment"># utf8なURLをデコード</span>
<span class="synStatement">my</span> <span class="synIdentifier">$utf8_encode</span> = <span class="synStatement">pop</span>(<span class="synIdentifier">@url_split</span>);
<span class="synStatement">my</span> <span class="synIdentifier">$utf8</span> = uri_unescape(<span class="synIdentifier">$utf8_encode</span>);
<span class="synComment"># UTF-8に変換</span>
<span class="synStatement">my</span> <span class="synIdentifier">$temp</span> = decode( <span class="synConstant">'utf8'</span>, <span class="synIdentifier">$utf8</span> );
<span class="synComment"># Shift-JISに変換</span>
<span class="synIdentifier">$temp</span> = encode( <span class="synConstant">'shiftjis'</span>, <span class="synIdentifier">$temp</span> );
<span class="synComment"># 再度エンコード</span>
<span class="synIdentifier">$temp</span> = uri_escape(<span class="synIdentifier">$temp</span>);
<span class="synStatement">push</span>( <span class="synIdentifier">@url_split</span>, <span class="synIdentifier">$temp</span> );
<span class="synStatement">return</span> {<span class="synConstant">'shiftjis'</span> =&#62; <span class="synStatement">join</span>( <span class="synConstant">'='</span>, <span class="synIdentifier">@url_split</span> ), <span class="synConstant">'utf-8'</span> =&#62; <span class="synIdentifier">$_</span>-&#62;as_string};
}
];
process <span class="synConstant">'//td[@class=&#34;SelectFromPlace&#34;]//a'</span>, <span class="synConstant">'citys[]'</span> =&#62; <span class="synConstant">'@href'</span>;
};
<span class="synComment"># スクレイピングの実行</span>
<span class="synStatement">my</span> <span class="synIdentifier">$result</span> = <span class="synIdentifier">$scraper</span>-&#62;scrape(<span class="synIdentifier">$uri</span>);
say YAML::Dump(<span class="synIdentifier">$result</span>);
</pre>
<h4>
実行例
</h4>
<pre class="syntax-highlight">
kazu634@srv634% perl <span class="synStatement">test</span>.pl ~/work/tmp_perl/scrap <span class="synStatement">[</span><span class="synConstant">6054</span><span class="synStatement">]</span>
---
citys:
- <span class="synStatement">!!</span>perl/scalar:URI::http http://www.starbucks.co.jp/search/tokyo.php
- <span class="synStatement">!!</span>perl/scalar:URI::http http://www.starbucks.co.jp/search/kanagawa.php
- <span class="synStatement">!!</span>perl/scalar:URI::http http://www.starbucks.co.jp/search/osaka.php
prefs:
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%96k%8AC%<span class="synConstant">93</span>%B9
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%8C%<span class="synConstant">97</span>%E6%B5%B7%E9%<span class="synConstant">81</span>%<span class="synConstant">93</span>
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">90</span>%C2%90X%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E9%9D%<span class="synConstant">92</span>%E6%A3%AE%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8A%E2%8E%E8%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%B2%A9%E6%<span class="synConstant">89</span>%8B%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8B%7B%8F%E9%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%AE%AE%E5%9F%8E%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8FH%93c%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E7%A7%8B%E7%<span class="synConstant">94</span>%B0%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8ER%8C%<span class="synConstant">60</span>%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%B1%B1%E5%BD%A2%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">95</span>%9F%<span class="synConstant">93</span>%<span class="synConstant">87</span>%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E7%A6%8F%E5%B3%B6%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">88</span>%EF%8F%E9%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E8%8C%A8%E5%9F%8E%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">93</span>%C8%<span class="synConstant">96</span>%D8%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E6%A0%<span class="synConstant">83</span>%E6%9C%A8%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8CQ%94n%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E7%BE%A4%E9%A6%AC%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8D%E9%8B%CA%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%9F%BC%E7%8E%<span class="synConstant">89</span>%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">90</span>%E7%97t%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%8D%<span class="synConstant">83</span>%E8%<span class="synConstant">91</span>%<span class="synConstant">89</span>%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8ER%<span class="synConstant">97</span>%9C%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%B1%B1%E6%A2%A8%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">92</span>%B7%<span class="synConstant">96</span>%EC%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E9%<span class="synConstant">95</span>%B7%E9%<span class="synConstant">87</span>%8E%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%90V%8A%<span class="synConstant">83</span>%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E6%<span class="synConstant">96</span>%B0%E6%BD%9F%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%95x%8ER%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%AF%8C%E5%B1%B1%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">90</span>%CE%<span class="synConstant">90</span>%EC%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E7%9F%B3%E5%B7%9D%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">95</span>%9F%<span class="synConstant">88</span>%E4%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E7%A6%8F%E4%BA%<span class="synConstant">95</span>%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8E%A0%<span class="synConstant">89</span>%EA%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E6%BB%8B%E8%B3%<span class="synConstant">80</span>%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8B%9E%93s%<span class="synConstant">95</span>%7B
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E4%BA%AC%E9%<span class="synConstant">83</span>%BD%E5%BA%9C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">95</span>%BA%8C%C9%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%<span class="synConstant">85</span>%B5%E5%BA%AB%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%98a%<span class="synConstant">89</span>%CC%8ER%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%<span class="synConstant">92</span>%8C%E6%AD%8C%E5%B1%B1%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">93</span>%DE%<span class="synConstant">97</span>%C7%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%A5%<span class="synConstant">88</span>%E8%<span class="synConstant">89</span>%AF%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">92</span>%B9%8E%E6%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E9%B3%A5%E5%8F%<span class="synConstant">96</span>%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">93</span>%<span class="synConstant">87</span>%8D%AA%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%B3%B6%E6%A0%B9%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">89</span>%AA%8ER%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%B2%A1%E5%B1%B1%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8DL%<span class="synConstant">93</span>%<span class="synConstant">87</span>%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%BA%<span class="synConstant">83</span>%E5%B3%B6%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8ER%8C%FB%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%B1%B1%E5%8F%A3%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">95</span>%9F%<span class="synConstant">89</span>%AA%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E7%A6%8F%E5%B2%A1%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8D%B2%<span class="synConstant">89</span>%EA%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E4%BD%<span class="synConstant">90</span>%E8%B3%<span class="synConstant">80</span>%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">92</span>%B7%8D%E8%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E9%<span class="synConstant">95</span>%B7%E5%B4%8E%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8CF%<span class="synConstant">96</span>%7B%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E7%<span class="synConstant">86</span>%8A%E6%9C%AC%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">91</span>%E5%<span class="synConstant">95</span>%AA%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%A4%A7%E5%<span class="synConstant">88</span>%<span class="synConstant">86</span>%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8B%7B%8D%E8%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%AE%AE%E5%B4%8E%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8E%AD%8E%<span class="synConstant">99</span>%<span class="synConstant">93</span>%<span class="synConstant">87</span>%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E9%B9%BF%E5%<span class="synConstant">85</span>%<span class="synConstant">90</span>%E5%B3%B6%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">89</span>%AB%<span class="synConstant">93</span>%EA%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E6%B2%<span class="synConstant">96</span>%E7%B8%<span class="synConstant">84</span>%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">93</span>%BF%<span class="synConstant">93</span>%<span class="synConstant">87</span>%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%BE%B3%E5%B3%B6%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8D%<span class="synConstant">81</span>%<span class="synConstant">90</span>%EC%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E9%A6%<span class="synConstant">99</span>%E5%B7%9D%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">88</span>%A4%95Q%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E6%<span class="synConstant">84</span>%9B%E5%AA%9B%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8D%<span class="synConstant">82</span>%92m%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E9%AB%<span class="synConstant">98</span>%E7%9F%A5%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">90</span>%C3%<span class="synConstant">89</span>%AA%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E9%9D%<span class="synConstant">99</span>%E5%B2%A1%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%<span class="synConstant">88</span>%A4%92m%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E6%<span class="synConstant">84</span>%9B%E7%9F%A5%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8A%F2%<span class="synConstant">95</span>%8C%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E5%B2%<span class="synConstant">90</span>%E9%<span class="synConstant">98</span>%9C%E7%9C%8C
- shiftjis: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%8EO%8Fd%8C%A7
utf<span class="synConstant">-8</span>: http://www.starbucks.co.jp/search/result_city2.php?<span class="synIdentifier">SearchPerfecture</span>=%E4%B8%<span class="synConstant">89</span>%E9%<span class="synConstant">87</span>%8D%E7%9C%8C
</pre>
<p>
shift-jisとutf8でまったくURLが異なっていることに気づきましたかshift-jisだと、正常なページにリンクされますが、utf8なURLだと正常ではないページに飛んでいきます。
</p>
<p>
こんな機能があるだなんて、便利だ。
</p>
</div>