.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "WWW::Wikipedia 3pm" .TH WWW::Wikipedia 3pm "2017-11-12" "perl v5.26.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" WWW::Wikipedia \- Automated interface to the Wikipedia .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use WWW::Wikipedia; \& my $wiki = WWW::Wikipedia\->new(); \& \& ## search for \*(Aqperl\*(Aq \& my $result = $wiki\->search( \*(Aqperl\*(Aq ); \& \& ## if the entry has some text print it out \& if ( $result\->text() ) { \& print $result\->text(); \& } \& \& ## list any related items we can look up \& print join( "\en", $result\->related() ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" WWW::Wikipedia provides an automated interface to the Wikipedia , which is a free, collaborative, online encyclopedia. This module allows you to search for a topic and return the resulting entry. It also gives you access to related topics which are also available via the Wikipedia for that entry. .SH "INSTALLATION" .IX Header "INSTALLATION" To install this module type the following: .PP .Vb 4 \& perl Makefile.PL \& make \& make test \& make install .Ve .SH "METHODS" .IX Header "METHODS" .SS "\fInew()\fP" .IX Subsection "new()" The constructor. You can pass it a two letter language code, or nothing to let it default to 'en'. .PP .Vb 2 \& ## Default: English \& my $wiki = WWW::Wikipedia\->new(); \& \& ## use the French wiki instead \& my $wiki = WWW::Wikipedia\->new( language => \*(Aqfr\*(Aq ); .Ve .PP WWW::Wikipedia is a subclass of LWP::UserAgent. If you would like to have more control over the user agent (control timeouts, proxies ...) you have full access. .PP .Vb 3 \& ## set HTTP request timeout \& my $wiki = WWW::Wikipedia\->new(); \& $wiki\->timeout( 2 ); .Ve .PP You can turn off the following of wikipedia redirect directives by passing a false value to \f(CW\*(C`follow_redirects\*(C'\fR. .PP Together with the Wiki markup, some entries include \s-1HTML\s0 tags. They can be stripped out using the \f(CW\*(C`clean_html\*(C'\fR option: .PP .Vb 1 \& my $wiki = WWW::Wikipedia\->new( clean_html => 1 ); .Ve .PP See \f(CW\*(C`clean_html\*(C'\fR documentation below for details. .SS "\fIlanguage()\fP" .IX Subsection "language()" This allows you to get and set the language you want to use. Two letter language codes should be used. The default is 'en'. .PP .Vb 1 \& my $wiki = WWW::Wikipedia\->new( language => \*(Aqes\*(Aq ); \& \& # Later on... \& $wiki\->language( \*(Aqfr\*(Aq ); .Ve .SS "\fIclean_html()\fP" .IX Subsection "clean_html()" Allows you to get/set if \s-1HTML\s0 is being stripped out. .PP .Vb 2 \& # set HTML strip \& $wiki\->clean_html( 1 ); .Ve .PP This option removes all tags and attributes they might have. Their contents, however, is maintained (for now). Comments are also removed. .SS "\fIfollow_redirects()\fP" .IX Subsection "follow_redirects()" By default, wikipeda redirect directives are followed. Set this to false to turn that off. .SS "\fIsearch()\fP" .IX Subsection "search()" Which performs the search and returns a WWW::Wikipedia::Entry object which you can query further. See WWW::Wikipedia::Entry docs for more info. .PP .Vb 2 \& $entry = $wiki\->search( \*(AqPerl\*(Aq ); \& print $entry\->text(); .Ve .PP If there's a problem connecting to Wikipedia, \f(CW\*(C`undef\*(C'\fR will be returned and the error message will be stored in \f(CW\*(C`error()\*(C'\fR. .SS "\fIrandom()\fP" .IX Subsection "random()" This method fetches a random wikipedia page. .SS "\fIerror()\fP" .IX Subsection "error()" This is a generic error accessor/mutator. You can retrieve any searching error messages here. .SH "TODO" .IX Header "TODO" .IP "\(bu" 4 Be more specific on the \s-1HTML\s0 clean methodology. For now all tags are removed, keeping only their contents. In the future the behaviour might change accordingly with each specific tag. .IP "\(bu" 4 Watch the development of Special:Export \s-1XML\s0 formatting, eg: http://en.wikipedia.org/wiki/Special:Export/perl .SH "SEE ALSO" .IX Header "SEE ALSO" .IP "\(bu" 4 LWP::UserAgent .SH "REPOSITORY" .IX Header "REPOSITORY" .SH "AUTHORS" .IX Header "AUTHORS" Ed Summers .PP Brian Cassidy .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright 2003\-2017 by Ed Summers .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.