Thread Post-Daten an Server senden
(17 answers)
Opened by SirLant at 2003-08-14 22:33
ich habe mir diese funktion geschrieben, die auch cookies behandelt, damit kann man sich auch bei anderen seiten einloggen wenn cookies gefordert sind.
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 use strict; use LWP::UserAgent; use HTTP::Response; use HTTP::Request; use URI::Escape; sub formular_senden { my ($url, $formular, $cookie) = @_; my $ua = new LWP::UserAgent; $ua->agent("Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); #manche webserver blocken sonst my $content; $content .= $_.'='.uri_escape($formular->{$_}).'&' for (keys(%$formular)); chop($content); my $request = new HTTP::Request('POST', $url); $request->header('Cookie' => $cookie) if $cookie; $request->content($content); my $response = $ua->request($request); die ($respnse->error_as_HTML) if $response->is_error(); $cookie = $response->header('Set-Cookie'); #print $response->as_string(); return $response->content(), $cookie; } <!--EDIT|kmonster|1061839811--> |