Skip to content

Instantly share code, notes, and snippets.

@xtetsuji
Created May 26, 2018 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xtetsuji/aa33d170d052aef48f4aa5eef3da9244 to your computer and use it in GitHub Desktop.
Save xtetsuji/aa33d170d052aef48f4aa5eef3da9244 to your computer and use it in GitHub Desktop.
Scraper from Yahoo! JP Fortune.
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Encode;
use HTTP::Tiny;
binmode STDOUT, ':utf8';
my $http = HTTP::Tiny->new();
my $res = $http->get("https://fortune.yahoo.co.jp/12astro/ranking.html");
my $body = decode('euc-jp', $res->{content});
my @lines = split /\n/, $body;
my @seizas;
for my $line (@lines) {
if ( $line =~ /seiza-bg0[12]/ ) {
#print $line, "\n";
my ($seiza) = $line =~ /alt="(.+?)"/;
#print ">>> seiza => $seiza\n";
if ( $seiza ) {
push @seizas, $seiza;
}
}
}
my $rank = 1;
for my $seiza (@seizas) {
print "$rank $seiza\n";
$rank++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment