source: lab/trunk/Dev/pukiwikiplus/getsource.pl @ 120

Last change on this file since 120 was 120, checked in by mitty, 13 years ago
  • script for Pukiwiki Plus!
  • getsource.pl -> getting pukiwiki formatted source from Pukiwiki Plus! pages
File size: 556 bytes
Line 
1#! /usr/bin/perl
2
3use strict;
4use warnings;
5use utf8;
6
7use Web::Scraper;
8use URI;
9use Data::Validate::URI qw(is_uri);
10use Encode;
11
12if (@ARGV < 1) {
13    print "$0: url_to_pukiwikiplus_page\n";
14    exit;
15}
16
17my $url = $ARGV[0];
18die "$0: '$url' is not URI" unless is_uri($url);
19
20if ($url !~ /cmd=source/ ) {
21    $url =~ s#\?(.+)#\?cmd=source&page=$1#;
22}
23
24print STDERR "getting: '$url'\n";
25
26my $source = scraper {
27    process "pre#source", "source" => "TEXT";
28    result "source";
29};
30
31my $text = $source->scrape( URI->new($url) );
32
33print encode('utf8', $text);
Note: See TracBrowser for help on using the repository browser.