Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

perlaintdead's scratchpad

by perlaintdead (Scribe)
on May 21, 2011 at 23:48 UTC ( #906105=scratchpad: print w/replies, xml ) Need Help??

$|=1; use LWP::UserAgent; use HTTP::Headers; use HTTP::Message; use JSON; my $weatherSeeker = LWP::UserAgent->new(); #make Useragent look more human $weatherSeeker->agent('Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like +Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 +Mobile/8A293 Safari/6531.22.7'); #iphone $weatherSeeker->default_header('Accept-Language' => 'en-US,en;q=0.5'); $weatherSeeker->default_header('X-Requested-With' => 'XMLHttpRequest') +; my $randomNum = rand 10000; #idk wft nws is whack #changes this based on your location my $lat = 1; my $lon = 1; while(1){ print scalar localtime, "\n"; my $JSONresp = $weatherSeeker->get(' +MapClick.php?rand=' . $randomNum . '&lat=' . $lat . '&lon=' . $lon . +'&FcstType=digitalJSON')->decoded_content; print packagereport($JSONresp); $randomNum = rand 10000; sleep aboutAnHour(); print "*" x 50, "\n\n"; } sub packagereport{ my $JSONresponce = shift; my $final = ""; $JSONresponce =~ s/(\x20|\t|\r|\n)//g; my $report = decode_json($JSONresponce); my @desiredStats = ('weather','temperature','windSpeed','cloudAmou +nt','relativeHumidity','windDirectionCardinal',); my $period = ""; if(defined $report->{'Today'}){ $period = 'Today'; }elsif(defined $report->{'Tonight'}){ $period = 'Tonight'; }elsif(defined $report->{'Overnight'}){ $period = 'Overnight'; }else{ print "Period not found. Using Sunday\n"; $period = 'Sunday'; } for my $stat (@desiredStats){ $final .= ucfirst($stat) . ": " . $report->{$period}->{$stat}[ +0] . "\n"; } $final .= "\n"; if($final =~ m/(rain|hail|snow|thunderstorms)/i){ ### alert on awe +some weather $final .= "\a"; } return $final; } sub aboutAnHour(){ #more closly resembles legitimate usage. return( 3600 + int rand 1800 ); }
Log In?

What's my password?
Create A New User
[Lady_Aleena]: Why XP?
[Discipulus]: it is for my father: it is impossible to tell him to learn a newer OS
[Lady_Aleena]: To tell him or teach him?
Discipulus anyway xp is still the best lowend game machine
[Discipulus]: both: everyting must be identical in the new v-machine
[Lady_Aleena]: So putting a nice DE or WM up on a Linux machine is not an option?
[Discipulus]: i need some converter to have directly an OVF format directly: at the moment i'm trying with vmware converter standalone
[Lady_Aleena]: I don't know what to tell you. I can barely get my Linux machine to do things I want.
[Discipulus]: if DE or WM means desktop env and win manager.. no, not an option

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2017-05-22 18:38 GMT
Find Nodes?
    Voting Booth?