500 Can't connect to search.cpan.org:80 (Bad hostname) at C:/Programme/Apache/cgi-bin/parsetesta.pl line 20.\r
$ua->protocols_allowed( [ 'http','https'],'http://surfproxy.prox:8080');
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
print "Content-type:text/html\n\n"; use LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->protocols_allowed( [ 'http','https'],'http://surfproxy.prox:8080'); #$ua->protocols_allowed( [ 'http','https'],'http://surfproxy.prox:8080'); #$ua->env_proxy; my $response = $ua->get('http://search.cpan.org/'); if ($response->is_success) { print $response->content; # or whatever } else { die $response->status_line; }
2012-04-25T11:02:11 perl-snaksCode: (dl )500 Can't connect to search.cpan.org:80 (Bad hostname) at C:/Programme/Apache/cgi-bin/parsetesta.pl line 20.\r
(...)
Code: (dl )$ua->protocols_allowed( [ 'http','https'],'http://surfproxy.prox:8080');
(...)
Code (perl): (dl )1 2$ua->protocols_allowed( [ 'http','https'],'http://*****:8080'); #$ua->protocols_allowed( [ 'http','https'],'http://*****:8080');
1 2 3
$ua->protocols_allowed( [ 'http','https'],'http://*****:8080'); $ua->protocols_allowed( [ 'http','https'],'http://*****:8080'); $ua->protocols_allowed( [ 'http','https'],'http://surfproxy.prox:8080');
1 2 3 4 5 6
$ua->proxy( http => 'http://*****:8080'); $ua->proxy( https => 'http://*****:8080'); $ua->proxy( http => 'http://*****:8080'); $ua->proxy( https => 'http://*****:8080'); $ua->proxy( http => 'http://surfproxy.prox:8080'); $ua->proxy( https => 'http://surfproxy.prox:8080');
$ua->proxy([ 'http','https' ],'http://surfproxy.prox:8080');
1
2
3
4
5
6
$ua->credentials('p****.eu:443',relam,'user' , 'psw');
Aber es hat wieder den fehler
[code]500 Can't connect to 'p****.eu:443 (Bad hostname).
$ua->credentials('p****.eu:443','relam','user' , 'psw');
$ua->ssl_opts (SSL_ca_file => "PFAD_ZU_CA_FILE.cert");
2012-04-25T13:09:11 perl-snaksExistiert der Server denn unter dem Domainnamen, mit dem er abgefragt wurde?500 Can't connect to XYZ.server.eu:443 (Bad hostname)Can't connect to XYZ.server.eu:443 (Bad hostname) LWP::Protocol::https::Socket: Bad hostname 'XYZ.server.eu:443 ' at C:/Perl/lib/LWP/Protocol/http.pm line 51.
use LWP::Debug qw(+);
2012-04-25T13:09:11 perl-snaksich meinte eine globale Datei, die alle Root-CA-Zertifikate enthält. In Linux gibt es sowas. Aber vielleicht klappt es ja auch ohne, wenn das gültige Zertifikate sind.Welche Zertifkat meien Sie?
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
#!C:\Perl\bin\Perl.exe -w print "Content-type:text/html\n\n"; use strict; use LWP::UserAgent; use LWP::Debug qw(+); my $pw='abcdefg'; my $us='123456'; my $url = "https://xyz.server.de/bbb/lala.php"; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->requests_redirectable(undef); # Redirects ausschalten! my $response = $ua->post($url,[0=>0]); print $response->status_line; print $response->decoded_content; Für jeden Hinweis bedanke ich mich.
1
2
3
4
5
6
7
8
9
10
11
12
Server:
194.105.56.3
Address:
194.105.56.3#53
Non-authoritative answer:
Name:
www.heise.de
Address:
193.99.144.85
use LWP::Debug qw(+);
1 2
$ua->add_handler("request_send", sub { shift->dump; return }); $ua->add_handler("response_done", sub { shift->dump; return });
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
#!C:\Perl\bin\Perl.exe -w print "Content-type:text/html\n\n"; use strict; use LWP::UserAgent; use LWP::Debug qw(+); my $pw='abcdefg'; my $us='123456'; my $url = "https://xyz.server.eu/lala.php"; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->requests_redirectable(undef); # Redirects ausschalten! $ua->credentials("++++.******.de:443", "Realname", $us, $pw); $ua->add_handler("request_send", sub { shift->dump; return }); $ua->add_handler("response_done", sub { shift->dump; return }); my $response = $ua->post($url,[0=>0]); print $response->status_line; print $response->decoded_content;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Content-type:text/html
User-Agent: libwww-perl/6.02
Content-Length: 3
Content-Type: application/x-www-form-urlencoded
0=0
500 Can't connect to xyz.server.de (Bad hostname)\n
Content-Type: text/plain
Client-Date: Wed, 25 Apr 2012 14:18:33 GMT
Client-Warning: Internal response
Can't connect to xyz.server.de(Bad hostname)\n
LWP::Protocol::https::Socket: Bad hostname xyz.server.de ' at C:/Perl/liProtocol/http.pm line 51.\n
[i][b]modedit[/b] Editiert von [user]642[/user]: CODE-Tags repariert[/i]
2012-04-27T12:11:56 perl-snaksEben, es wurde kein DNS-Eimntrag für dei Domain gefunden, deswegen kommt in deinem Programm auch Bad Hostname.Hey vielen Dank für die Antwort.
Wenn ich nslookup xxy.server.eu in der Eingabeaufforderung eingebe,
bekomme ich die fehlermeldun:
wurde nicht gefunden: Non-existent domain.
QuoteAber ich denke, dass es nicht daran liegt, sondern ligt,das die Seite, die ich mittels LWP aufrufen möchte, verwendet ein HTTPS request.
Wenn ich z.B http://google.com/ mit meiner Skript aufrufe, wird die seite zu goole weitergeleitet.
Die Secure Seiten https aber nicht. hab glesen, dass ich oder
Crypt::SSLeay
WWW::Curl::Easy benötige, um ein request zu bekommen.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
use strict; use warnings; use LWP::UserAgent; my $pw='abcdefg'; my $us='1234567'; my $url = "https://poms-test.ts.fujitsu.com/CallLog"; my $ua = LWP::UserAgent->new; $ua->requests_redirectable(undef); # Redirects ausschalten! $ua->credentials("poms-test.ts.fujitsu.com:443", "POMS2", $us, $pw); $ua->proxy( http => 'http://wwwproxy.bank.dresdner.net:8080'); $ua->add_handler("request_send", sub { shift->dump; return }); $ua->add_handler("response_done", sub { shift->dump; return }); my $response = $ua->post($url,[0=>0]); print $response->status_line; print $response->decoded_content;
1
2
3
4
5
6
7
8
9
10
11
12
13
POST https://poms-test.ts.fujitsu.com/CallLog
User-Agent: libwww-perl/6.02
Content-Length: 3
Content-Type: application/x-www-form-urlencoded
0=0
500 Can't connect to poms-test.ts.fujitsu.com:443 (Bad hostname)
Content-Type: text/plain
Client-Date: Fri, 27 Apr 2012 12:38:54 GMT
Client-Warning: Internal response Can't connect to poms-test.ts.fujitsu.com:443 (Bad hostname)
LWP::Protocol::https::Socket: Bad hostname 'poms-test.ts.fujitsu.com' at C:/Perl/lib/LWP/Protocol/http.pm line 51.
500 Can't connect to poms-test.ts.fujitsu.com:443 (Bad hostname)Can't connect to poms-test.ts.fujitsu.com:443 (Bad hostname)
LWP::Protocol::https::Socket: Bad hostname 'poms-test.ts.fujitsu.com' at C:/Perl/lib/LWP/Protocol/http.pm line 51.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
use strict; use warnings; use LWP::UserAgent; my $pw='abcdefg'; my $us='1234567'; my $url = "https://poms-test.ts.fujitsu.com/CallLog"; my $ua = LWP::UserAgent->new; $ua->requests_redirectable(undef); # Redirects ausschalten! $ua->credentials("poms-test.ts.fujitsu.com:443", "POMS2", $us, $pw); $ua->proxy( https => 'http://www-proxy.t-online.de'); $ua->add_handler("request_send", sub { shift->dump; return }); $ua->add_handler("response_done", sub { shift->dump; return }); my $response = $ua->post($url,[0=>0]);
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 29 30 31
use strict; use LWP::UserAgent; my $url = "https://server.xyz.de/about.php"; my $pw='123456'; my $us='abcdef'; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->requests_redirectable(undef); # Redirects ausschalten! $ua->credentials("server.xyz.de:443", "POP3", $us, $pw); $ua->proxy( https => 'http://my.proxy:8080'); $ua->add_handler("request_send", sub { shift->dump; return }); $ua->add_handler("response_done", sub { shift->dump; return }); my $response = $ua->post($url); if ($response->is_success) { print $response->status_line; print $response->decoded_content; # or whatever } else { die $response->status_line; }
1
2
3
4
5
6
7
8
9
10
11
12
POST https://server.xyz.de/about.php
User-Agent: libwww-perl/6.02
Content-Length: 0
Content-Type: application/x-www-form-urlencoded
(no content)
HTTP/1.1 401 Unauthorized
ACCESS DENIED\n
401 Unauthorized at urlredirect.pl line 46.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Content-type:text/html POST https://server.xyz.de./blala.com User-Agent: libwww-perl/6.02 Content-Length: 0 (no content) HTTP/1.1 401 Unauthorized ACCESS DENIED\n POST https://server.xyz.de./blala.php (no content)
2012-05-04T10:35:33 perl-snaksgeeditet.
2012-05-04T09:27:18 perl-snaksSo geht das nun wirklich NICHT!credential(server, realm= "pop3 server name",$usr,$psw) eingegeben aber kommt leider die gleiche fehlermeldung:
$ua->credentials("server.xyz.de:443", "pop3 server name", $us, $pw);
my $ua = LWP::UserAgent->new;
$ua->agent( "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko Firefox/11.0" );
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 29 30 31 32 33
print "Content-type:text/html\n\n"; use strict; #use LWP::Simple; use LWP::UserAgent; use CGI; use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; my $var = CGI::param('wert'); my $url1 = 'https://server.xyz.de/psp.php'; my $url2 = 'wert=$var&save_report=yes' ; my $ua = LWP::UserAgent->new; $ua->agent( "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko Firefox/11.0" ); $ua->timeout(10); $ua->requests_redirectable(undef); # Redirects ausschalten! my $response = $ua->post($url); if ($response->is_success) { print $response->content; # or whatever } else { die $response->status_line; }
Quotebei diesem Skript bekomme ich die Fehlermeldung:
"400 URL must be absolute at C://Apache/cgi-bin/test.pl line 52" was mir nichts viel sagt:
my $response = $ua->post($url1$var);
perldoc LWP::UserAgent...
$ua->post( $url, \%form )
$ua->post( $url, \@form )
$ua->post( $url, \%form, $field_name => $value, ... )
$ua->post( $url, $field_name => $value,... Content => \%form )
$ua->post( $url, $field_name => $value,... Content => \@form )
$ua->post( $url, $field_name => $value,... Content => $content )
This method will dispatch a POST request on the given $url, with %form or @form providing the key/value pairs for the fill-in form content. Additional headers and content options are the same as for the get() method.
This method will use the POST() function from HTTP::Request::Common to build the request. See HTTP::Request::Common for a details on how to pass form content and other advanced features.
...
$ua->post( $url, { wert => 123456 } );