#! /usr/bin/perl use LWP::Simple; use LWP::UserAgent; use Time::ParseDate; use Time::Zone; my $GETTIMELIMIT = 30; # official eBay-Time: PST and MEZ my $url = 'http://cgi3.ebay.de/aw-cgi/eBayISAPI.dll?TimeShow'; my @L = ladeEbay( $url ); # print "loaded:\t",scalar @L,"\n"; %time = ( myTime => tz_local_offset() ); print "\n"; while ( @L) { my $l = shift(@L); if ( $l =~ s/(\(eBay\-Zeit\))//) { $l =~ s/^(.+?>)//g; $l =~ s/(<.+?>)/ /g; #print "\nzeit1:\t$l\n"; my @i = split /[\s,\.]+/, $l; #print join '; ', @i, "\n\n"; #$i[0] = "$2 $1 $3" if ($i[0] =~ /(\w+)[\s-](\d+)[\s-](\d+)/); my @i = split /[\s,\.]+/, $l; $time{usaDay} = "$i[4] $i[5] $i[6]"; $i[7] =~ s/://g; #hhmmss[[AP]M] $i[7] .= ($i[7] lt '120000' ) ? ' AM':' PM'; $time{usaTime} = $i[7]; $time{usaTiZo} = $i[8]; $time{usaOFF} = tz_offset($i[8]); next; } if ( $l =~ s/(<B>eBay\s*Deutschland)//) { $l =~ s/^(.+?>)//g; $l =~ s/(<.+?>)/ /g; #print "zeit2:\t$l\n"; my @i = split /[\s,\.]+/, $l; #print join '; ', @i, "\n\n"; my @i = split /[\s,\.]+/, $l; $time{brdDay} = "$i[2] $i[3] $i[4]"; $i[5] =~ s/://g; #hhmmss[[AP]M] $i[5] .= ($i[5] lt '120000' ) ? ' AM':' PM'; $time{brdTime} = $i[5]; $time{brdTiZo} = $i[6]; $time{brdOFF} = tz_offset($i[6]); last; } } $time{difOFF} = $time{brdOFF} - $time{usaOFF}; $time{usaSec} = parsedate($time{usaDay}.' '.$time{usaTime}, ZONE => $t +ime{usaTiZo}); $time{brdSec} = parsedate($time{brdDay}.' '.$time{brdTime}, ZONE => $t +ime{brdTiZo}); $time{diTime} = $time{brdSec} - $time{usaSec}; foreach (sort keys %time) { print "\t$_ => \t$time{$_}\n"; } print "\n"; sub ladeEbay { my $s; eval { local $SIG{ALRM} = sub { die "Zeit_Limit $!"}; alarm($GETTIMELIMIT); # 30 Sekunden = 0.5 min für ein get my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(GET => $url); $s = $ua->request($req)->as_string; alarm(0); }; if ($@ and ($@ =~ /Zeit_Limit/) ) {# da steht u.a. "Zeit_Limit" dr +in $ERRORMAIL .="TIMEOUT, NIX GELADEN (30 sec): $@\n"; alarm(0); return; } $s =~ s/\x0A|\x0D//g; return split /<table|<td|<tr/i, $s; }
In reply to TimeZone Error? by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |