usemod-search.pl 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #! /usr/bin/perl
  2. # Copyright (C) 2003 Alex Schroeder <alex@emacswiki.org>
  3. #
  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 3 of the License, or
  7. # (at your option) any later version.
  8. #
  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.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. use CGI qw/:standard/;
  17. use CGI::Carp qw(fatalsToBrowser);
  18. use LWP::UserAgent;
  19. if (not param('url')) {
  20. print header(),
  21. start_html('UseMod Search RSS 3.0'),
  22. h1('UseMod Search RSS 3.0'),
  23. p('Translates a UseMod Search result into RSS 3.0 usable by Oddmuse.'),
  24. start_form(-method=>'GET'),
  25. p('Search URL: ', textfield('url'), submit()),
  26. end_form(),
  27. end_html();
  28. exit;
  29. }
  30. print header(-type=>'text/plain; charset=UTF-8');
  31. my $ua = new LWP::UserAgent;
  32. my $request = HTTP::Request->new('GET', param('url'));
  33. my $response = $ua->request($request);
  34. my $data = $response->content;
  35. $data =~ /\<title\>([^<]*)/i;
  36. print "title: $1\n" if $1;
  37. print "link: " . param('url') . "\n\n";
  38. while ($data =~ /\n\<a[^>]*\>([^<]*)\<\/a\>\<br\>/gi) {
  39. print "title: $1\n\n";
  40. }