Thread JSON und Perl
(5 answers)
Opened by sleep at 2015-10-06 09:04
So ganz verstehe ich nicht was von wo abgeholt wird.
Aber ich zeige dir mal wie du Daten abholen kannst und von JSON dekodierts. Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 use LWP::UserAgent; use JSON; my $start_url = "http://localhost/abfrage1/42/JSON"; my $next_url; use LWP::UserAgent; use JSON; my $json = JSON->new; my $ua = LWP::UserAgent->new; my $response = $ua->get($start_url); if (not $response->is_success) { die $response->status_line; } my $hash = $json->decode($response->content); my $id = $hash{'id'}; $next_url = "http://localhost/abfrage2/$id"; $response = $ua->get( $next_url ); if (not $response->is_success) { die $response->status_line; } $hash = $json->decode($response->content); |