Prev / Next

2008-08-27 / chalow 用ケータイサイトマップ生成スクリプト

clkeitai.cgi に AdSense をつけたついでに,
google 向けケータイサイトマップ生成 script を書いてみた.
といっても,cli2sitemap.pl を書き換えただけ.


#!/usr/bin/perl

# usage
# perl cli2sitemap.pl cl.itemlist > sitemap.xml

use strict;
my %hash;
while (<>) {
    $hash{$1} = $hash{$2} = $hash{$3} = 1
      if (/^<a href=\"(((\d+-\d+)-\d+)-\d+)/);
}
my $xml;
foreach (sort keys %hash) {
    if (length($_) > 10){
    $xml .= << "URL"
<url>
<loc>http://www.ftnk.jp/~fumi/cl/clkeitai.cgi?date=$_</loc>
<mobile:mobile/>
</url>
URL
;
    }
}
print << "XML"
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84"
 xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0">
<url>
<loc>http://www.ftnk.jp/~fumi/cl/clkeitai.cgi</loc>
<mobile:mobile/>
</url>
$xml
</urlset>
XML
  ;


comments powered by Disqus