wiki.pl: Port some fixes from upstream
[Orgmuse.git] / usemod-search.pl
blobb8b2789814a053926cf26b74f038bce9c97bbe09
1 #! /usr/bin/perl
2 # Copyright (C) 2003 Alex Schroeder <alex@emacswiki.org>
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the
16 # Free Software Foundation, Inc.
17 # 59 Temple Place, Suite 330
18 # Boston, MA 02111-1307 USA
20 use CGI qw/:standard/;
21 use CGI::Carp qw(fatalsToBrowser);
22 use LWP::UserAgent;
24 if (not param('url')) {
25 print header(),
26 start_html('UseMod Search RSS 3.0'),
27 h1('UseMod Search RSS 3.0'),
28 p('Translates a UseMod Search result into RSS 3.0 usable by Oddmuse.'),
29 start_form(-method=>'GET'),
30 p('Search URL: ', textfield('url'), submit()),
31 end_form(),
32 end_html();
33 exit;
36 print header(-type=>'text/plain; charset=UTF-8');
38 my $ua = new LWP::UserAgent;
39 my $request = HTTP::Request->new('GET', param('url'));
40 my $response = $ua->request($request);
41 my $data = $response->content;
43 $data =~ /\<title\>([^<]*)/i;
44 print "title: $1\n" if $1;
45 print "link: " . param('url') . "\n\n";
47 while ($data =~ /\n\<a[^>]*\>([^<]*)\<\/a\>\<br\>/gi) {
48 print "title: $1\n\n";