Geo-Weather
view release on metacpan or search on metacpan
* timeout
Controls the timeout, in seconds, when trying to connect to or get data
from weather.com. Default timeout is 10 seconds. Set to 0 to disable
timeouts.
* proxy
Use HTTP proxy for the request. Format is http://proxy.server:port/.
Default is no proxy.
* proxy_user
Sets the username to use for proxying. Defaults to the HTTP_PROXY_USER
environment variable, if set, or don't use authentication if blank.
* proxy_pass
Sets the password to use for proxying. Defaults to the HTTP_PROXY_PASS
environment variable, if set.
* agent_string
HTTP User-Agent header for request. Default is Geo::Weather/$VERSION.
AUTHOR
Geo::Weather was wrtten by Mike Machado <mike@innercite.com>
$results{url} .= $page;
$results{page} = $page;
my $not_found_marker = 'not found';
my $end_report_marker = '<!-- vertical outlet #1 -->';
my $line = '';
print STDERR __LINE__, ": Geo::Weather: Attempting to GET current weather at $results{url}\n" if $self->{debug};
my $ua = new LWP::UserAgent;
my $request = new HTTP::Request('GET',$results{url});
my $proxy_user = $self->{proxy_user} || $ENV{HTTP_PROXY_USER} || '';
my $proxy_pass = $self->{proxy_pass} || $ENV{HTTP_PROXY_PASS} || '';
$request->proxy_authorization_basic($proxy_user, $proxy_pass) if $self->{proxy} && $proxy_user;
$ua->timeout($self->{timeout}) if $self->{timeout};
$ua->agent($self->{agent_string});
$ua->proxy(['http'], $self->{proxy}) if $self->{proxy};
my $response = $ua->request($request);
unless ($response->is_success) {
sub lookup_forecast {
my $self = shift;
my $url = shift;
my @forecast;
return $ERROR_QUERY unless $url;
print STDERR __LINE__, ": Geo::Weather: Attempting to GET forecast at $url\n" if $self->{debug};
my $ua = new LWP::UserAgent;
my $request = new HTTP::Request('GET', $url);
my $proxy_user = $self->{proxy_user} || $ENV{HTTP_PROXY_USER} || '';
my $proxy_pass = $self->{proxy_pass} || $ENV{HTTP_PROXY_PASS} || '';
$request->proxy_authorization_basic($proxy_user, $proxy_pass) if $self->{proxy} && $proxy_user;
$ua->timeout($self->{timeout}) if $self->{timeout};
$ua->agent($self->{agent_string});
$ua->proxy(['http'], $self->{proxy}) if $self->{proxy};
my $response = $ua->request($request);
unless ($response->is_success) {
Controls the timeout, in seconds, when trying to connect to or get data from weather.com. Default timeout
is 10 seconds. Set to 0 to disable timeouts.
=item * B<proxy>
Use HTTP proxy for the request. Format is http://proxy.server:port/. Default is no proxy.
=item * B<proxy_user>
Sets the username to use for proxying. Defaults to the HTTP_PROXY_USER environment variable, if set, or don't use authentication if blank.
=item * B<proxy_pass>
Sets the password to use for proxying. Defaults to the HTTP_PROXY_PASS environment variable, if set.
=item *B<agent_string>
HTTP User-Agent header for request. Default is Geo::Weather/$VERSION.
=head1 AUTHOR
Geo::Weather was wrtten by Mike Machado I<E<lt>mike@innercite.comE<gt>>
=cut
print "Enter state of location you are at: ";
my $state = <STDIN>;
chomp($state);
print "Proxy (just press enter if no proxy): ";
my $proxy = <STDIN>;
chomp($proxy);
$weather->{proxy} = $proxy;
if ($proxy) {
unless ($ENV{HTTP_PROXY_USER}) {
print "Proxy Username: ";
my $proxy_user = <STDIN>;
chomp($proxy_user);
$weather->{proxy_user} = $proxy_user;
}
unless ($ENV{HTTP_PROXY_PASS}) {
print "Proxy Password: ";
my $proxy_pass = <STDIN>;
chomp($proxy_pass);
$weather->{proxy_pass} = $proxy_pass;
}
}
print "Attempting to connect to weather.com...\n\n";
( run in 1.250 second using v1.01-cache-2.11-cpan-71847e10f99 )