File: search-ccsb

package info (click to toggle)
search-ccsb 0.5-6
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 140 kB
  • sloc: sh: 54; perl: 40; lisp: 15; makefile: 15
file content (89 lines) | stat: -rwxr-xr-x 2,326 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/perl

# Copyright (C) 2002 Rodrigo Araujo Real
     
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with GNU Emacs; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.    
#
# This file is neither part of XEmacs nor GNU Emacs. 

use HTTP::Request::Common;
use LWP::UserAgent;

$Ua = LWP::UserAgent->new;
$Ua->agent("Mozilla (compatible: LWP $LWP::VERSION)");

$res = $Ua->request(POST 'http://liinwww.ira.uka.de/csbib', [query => $ARGV[0], results => "bibtex"]);
die "Error while getting ", $res->request->uri,
          " -- ", $res->status_line, "\nAborting"
         unless $res->is_success;

$str=$res->content;
# extracts everything before the first <pre>
$str=~s/^.*?<pre>//s;

# extracts everything before the last </pre>
$str=~s/^(.*)<\/pre>.*/\1/s;

# extracts everything between </pre> and <pre>
$str=~s/<\/pre>.*?<pre>//gs;

# extracts any other unwanted HTML tags
$str=~s/<.*?>//gs;

if ($str =~ /Sorry, no references found/) {
    print "------------> No references found for $ARGV[0] <------------\n";
    exit(0);
}

print "------------> Search Expression: $ARGV[0] Results <------------\n";
print "$str";

exit(0);

__END__

=head1 NAME

search-ccsb

=head1 SYNOPSIS

search-ccsb <expression>

=head1 DESCRIPTION

This Perl script helps searching the "The Collection of Computer
Science Bibliographies" provided by Alf-Christian Achilles
<[email protected]>. With it you can perform a query without
browser, directly from the command line.

=head1 EXAMPLE

search-ccsb "operating systems"

=head1 CONTRIBUTORS

Mario Domenech Goulart, Otavio Salvador

=head1 SEE ALSO

The Collection of Computer Science Bibliographies
http://liinwww.ira.uka.de/bibliography/index.html

=head1 COPYRIGHT

Copyright 2002 Rodrigo Araujo Real.

=cut