WebSer...e::Web(3pm)
β¨ WebService::CIA::Source::Web β¨
okay bestie, gather round, because this is a 3pm section page from the User Contributed Perl Documentation and it's literally about pulling data straight off the live internet. no cap. π¦
π NAME π
WebService::CIA::Source::Web β it's an interface to the online CIA World Factbook. that's it, that's the whole vibe. π
π SYNOPSIS π
use WebService::CIA::Source::Web;
my $source = WebService::CIA::Source::DBM->new();
yes bestie, that second line says DBM and we are keeping it exactly as written. the manpage said it, so I say it. periodt. π
πΈ DESCRIPTION πΈ
WebService::CIA::Source::Web is your lil' gateway to the live, online version of the CIA World Factbook. like, the actual website. right now. over the network. πβ¨
ngl, it's a very slow way of doing things β it's giving dial-up energy β but here's the slay: it requires no pre-compiled DBM. none. zero. so it's way more likely to be useful for proving concepts or testing. lowkey perfect for that. π₯
π METHODS π
okay so listen: apart from new, these methods are normally accessed via a WebService::CIA object. iykyk. π
new( \%opts )
my $source = WebService::CIA::Source::Web->new();
$source = WebService::CIA::Source::Web->new( { user_agent => $ua } );
This method creates a new WebService::CIA::Source::Web object. it takes an optional hashref of arguments, bestie. and here's the one it knows:
user_agentβ a user agent object to use. it must implement the same user interface asLWP::UserAgent(or, at the very least, aget()method). don't try to sneak in something that can'tget(), okay? π«Ά
value($country_code, $field)
Retrieve a value from the web. π
$country_code should be the FIPS 10-4 country code as defined in <https://www.cia.gov/library/publications/the-world-factbook/appendix/appendix-d.html>.
$field should be the name of the field whose value you want to retrieve, as defined in <https://www.cia.gov/library/publications/the-world-factbook/docs/notesanddefs.html>.
(also!! WebService::CIA::Parser creates four extra fields: URL, URL - Print, URL - Flag, and URL - Map β which are, respectively, the URLs of the country's Factbook page, the printable version of that page, a GIF map of the country, and a GIF flag of the country. iconic.) πΊοΈπ©
valuewill returnundefif the country or field cannot be found, or if there is an error GETing the page. the manpage is very honest about this: it "isn't ideal", but the author "can't think of the best way around it right now". we respect the transparency. π
all($country_code)
Returns a hashref of field-value pairs for $country_code, or an empty hashref if $country_code isn't available from the Factbook. no drama, just an empty hashref. π
get($country_code)
Retrieve and cache the data for a country. π₯
Returns 1 if successful, 0 if not. that's the whole report card.
cached($country_code)
Get/set the country code whose data is cached. π
cache($hashref)
Get/set a hashref of data for the current country. πΎ
parser()
Returns a reference to the WebService::CIA::Parser object being used. π
ua( $userAgent )
Returns a reference to the user agent object being used. by default this is an LWP::UserAgent object, but you can pass a different object in if you wish. your choice, your rules. π
last_response()
Returns the HTTP::Response object from the last request. receipts!! π§Ύβ¨
π§ CACHING π§
so, in order to make some small improvement in efficiency, WebService::CIA::Source::Web keeps a copy of the data for the last country downloaded in memory. one country. just the one. it's a lil' guy doing its best. π«Ά
β TO DO β
the wishlist, bestie:
- File system based caching of pages.
- User-definable stack of cached countries, rather than just one.
- Caching of last-modified headers; conditional GET.
π AUTHOR π
Ian Malpass (ian-cpan@indecorous.com)
πΈ COPYRIGHT πΈ
Copyright 2003-2007, Ian Malpass
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The CIA World Factbook's copyright information page (<https://www.cia.gov/library/publications/the-world-factbook/docs/contributor_copyright.html>) states:
The Factbook is in the public domain. Accordingly, it may be copied
freely without permission of the Central Intelligence Agency (CIA).
π¦ SEE ALSO π¦
WebService::CIAWebService::CIA::ParserWebService::CIA::Source::DBM
and that's the whole page, bestie!! this was perl v5.34.0, dated 2022-06-28, from the WebSer...e::Web(3pm) manpage. slay, go fetch some factbook data, and hydrate!! πβ¨π
π¦ where this page comes from
- debian bookworm: libwebservice-cia-perl 1.4-4
- debian trixie: libwebservice-cia-perl 1.4-4
- ubuntu noble: libwebservice-cia-perl 1.4-4
- ubuntu resolute: libwebservice-cia-perl 1.4-4
- ubuntu stonking: libwebservice-cia-perl 1.4-4
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms