source: lab.git/Dev/pukiwikiplus/getsource.pl @ 74f778c

trunk
Last change on this file since 74f778c was 74f778c, checked in by mitty <mitty@…>, 14 years ago
  • script for Pukiwiki Plus!
  • getsource.pl -> getting pukiwiki formatted source from Pukiwiki Plus! pages

git-svn-id: https://lab.mitty.jp/svn/lab/trunk@120 7d2118f6-f56c-43e7-95a2-4bb3031d96e7

  • Property mode set to 100644
File size: 556 bytes
RevLine 
[74f778c]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.