Skip to content

Instantly share code, notes, and snippets.

@moccos
Created June 21, 2021 17:44
Show Gist options
  • Save moccos/1fa6ee655b7ad14260da9748044d5737 to your computer and use it in GitHub Desktop.
Save moccos/1fa6ee655b7ad14260da9748044d5737 to your computer and use it in GitHub Desktop.
#!perl
# 読み飛ばす
while (<>) {
last if /<div class="horseList">/;
}
# テーブルをばらす
while (<>) {
if (/<h4 class="name">/) {
s/<.+?>//g;
s/\s//g;
$name = $_;
} elsif (m|<p class="seiseki">年齢:1 性別:(.+) 毛色:(.+)毛|) {
$sex = $1;
$keiro = $2;
} elsif (m|>父</span>(.+?)</p>|) {
$sire = $1;
} elsif (m|>母</span>(.+?)</p>|) {
$mare = $1;
} elsif (m|>母父</span>(.+?)</p>|) {
$bms = $1;
} elsif (m|>所属</span>(.+?)</p>|) {
$area = $1;
} elsif (m|>厩舎</span>(.+?)</p>|) {
$stable = $1;
} elsif (m|>育成牧場</span>.+>(.+)</span>|) {
$farm = $1
} elsif (m|一口出資額</span><strong class="red2">(\d+),000</|) {
$price = int($1) * 1000;
# ここで表示
$line = join("\t", ($name, $sex, $price, $sire, $mare, $bms, $area, $stable, $farm, $keiro)) . "\n";
$line =~ s/&#039;/'/g;
print $line;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment