Created
December 11, 2012 06:34
(perl script) get a stock price data from stocks.finance.yahoo.co.jp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Web::Scraper; | |
use URI; | |
use Encode; | |
my $scraper = scraper { | |
process '//dl[@class="stocksInfo"]/dt[1]','numb' => 'TEXT'; | |
process '//table[@class="stocksTable"]/tr[1]/th[1]','name' => 'TEXT'; | |
process '//table[@class="stocksTable"]/tr[1]/td[2]','price' => 'TEXT'; | |
process '//dl[@class="stocksInfo"]/dd[3]/span[1]','jikoku' => 'TEXT'; | |
}; | |
my $res = $scraper->scrape(URI->new("http://stocks.finance.yahoo.co.jp/stocks/detail/?code=9501.t")); | |
print $res->{numb}."\n"; | |
#print encode('shift-jis',$res->{name})."\n"; | |
print encode('sjis',$res->{name})."\n"; | |
print $res->{price}."\n"; | |
print $res->{jikoku}."\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment