LoginSignup
1
3

More than 5 years have passed since last update.

Amazon.comの500アイテムとAmazon.co.jpのアイテムの価格を一挙に比較するプログラム(パート3)

Posted at

パート3です。

整形するためのプログラムです。HTMLを出力します。

でもって、パート1〜パート3までのプログラムをパイプでつなげると動作します。

./ama.pl | ./comp_us_jp.pl | ./mkhtml.pl > output.html
もしくは、
./ama.pl | sort | uniq | ./comp_us_jp.pl | ./mkhtml.pl > output.html
として実行して下さい。

パート3は、おしまいです。

mkhtml.pl
#!/usr/bin/perl -w

$line = "";

print "<!DOCTYPE html>\n";
print "<html>\n";
print "<body>\n";
print "<table>\n";

    print "<tr>\n";
    print "<td>asin</td><td>jrank</td><td>jprice</td><td>rank</td><td>price</td><td>jurl</td><td>url</td><td>weight</td><td>diff</td><td>prime</td><td>sutable</td><td>totalnew</td>\n";
    print "</tr>\n";

while( $line = <STDIN> ){
    print "<tr>\n";
        chomp( $line );
    @words = split /\t/, $line;

    for( $i = 0 ; $i < @words; $i ++)
    {
        if ( $words[$i] =~ /http:([^ \t\n\r\f\v]*)/ ) 
        {

            print '<td><a href="' . $words[$i] . '">OOO</a></td>';
            print "\n";
        }
        else
        {
            print "<td>" . $words[$i] . "</td>\n";
        }
    }

    print "</tr>\n";
}
print "</table>\n";
print "</body>\n";
print "</html>\n";
1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3