lwp

Perl equivalent of PHP's get_file_contents()?

混江龙づ霸主 提交于 2019-12-14 00:48:46
问题 The following PHP code does exactly what I want to do. The problem is I need to re-create it in Perl and I've been playing around with the open() and sysopen() Perl functions but can't do it. Does anyone have any help or know of any links that might help? Thanks. $URL = "http://example.com/api.php?arguments=values"; echo file_get_contents($URL); 回答1: You can make use of LWP: use LWP::Simple; $contents = get $URL or die; print $contents; 来源: https://stackoverflow.com/questions/3413151/perl

LWP::UserAgent HTTP Basic Authentication

空扰寡人 提交于 2019-12-12 08:29:22
问题 I tried to run this perl5 program: #!/usr/bin/env perl use strict; use warnings; use LWP; my $ua = LWP::UserAgent->new('Mozilla'); $ua->credentials("test.server.com:39272", "realm-name", 'user_name', 'some_pass'); my $res = $ua->get('http://test.server.com:39272/'); print $res->content; On other hand I have HTTP::Daemon: #!/usr/bin/env perl use strict; use warnings; use HTTP::Daemon; my $hd = HTTP::Daemon->new or die; print "Contact URL: ", $hd->url, "\n"; while (my $hc = $hd->accept) { while

LWP Get Large File Download Headers Missing

你。 提交于 2019-12-11 21:33:47
问题 This post is follow on work related to LWP GET large file download. That post was regarding an error from LWP when trying to pass arguments in the header incorrectly. Now I am posting the changes I made and how I am trying to debug the approach. This discussion should be very informative for those interested in POST vs GET header formation, and what the server receives while using the CGI package. It is not information easily found on the net. Here is my client code snip: my $bytes_received =

HTML::TableExtract: how to run the right argument [see live example]

六月ゝ 毕业季﹏ 提交于 2019-12-11 12:32:10
问题 A question regarding a parser. Is there any chance to catch some separators within the that separate the table... The paser script runs allready nicely. Note - i want to store the data into a MySQL database. So it would be great to have some seperators - (commas, tabs or somewhat else - a tab seperated values or comma seperated values are handy formats to work with... ( here the data out of the following site: http://192.68.214.70/km/asps/schulsuche.asp?q=a&a=20 ) lfd. Nr. Schul- nummer

LWP set max_size but still get content

为君一笑 提交于 2019-12-11 09:34:37
问题 I am using LWP to get the content from some sites and whenever the page size is larger than one megabyte, I would like LWP to stop downloading the page. This is accomplished with this code: my $ua = LWP::UserAgent->new; $ua->max_size(1024); And it works fine. The only problem is that even when the page is over 1mb, I would still like to be able to get the content of what it has downloaded so far. However, whenever I do this (the traditional way to get content with LWP when there are no errors

perl 500 proxy connect failed: PROXY ERROR HEADER, could be non-SSL URL

青春壹個敷衍的年華 提交于 2019-12-11 09:13:55
问题 have a problem when i try to connect with web service that have certification , username and password as credentials 500 proxy connect failed: PROXY ERROR HEADER, could be non-SSL URL My code is below: use LWP::Debug qw(+); use HTTP::Request::Common; use Crypt::SSLeay; use HTTP::Headers; use HTTP::Request; use LWP; $url = "https://ip:port/service"; my $ua = new LWP::UserAgent; $ENV{HTTPS_DEBUG} = 1; $ENV{HTTPS_PROXY} = 'https://ip:port'; $ENV{HTTPS_PROXY_USERNAME} = "username"; $ENV{HTTPS

Issues with LWP when using HTTP/1.1: bad chunk-size, truncated responses

别等时光非礼了梦想. 提交于 2019-12-11 08:38:08
问题 I've been writing some Perl utilities to interact with some of my company's internal web sites. A while back I started encountering an intermittent error when accessing certain pages: "Bad chunk-size in HTTP response". I tracked this message down to the module Net::HTTP::Methods . I spent a little time trying to diagnose the ultimate origin of the error, but without success. Then somewhere I found a suggestion that setting the protocol of my HTTP requests to "HTTP/1.0" might help, and to my

How to make the post request in BOX API using LWP::UserAgent?

拟墨画扇 提交于 2019-12-11 05:08:47
问题 I have tried the following code my $url = "https://api.box.com/2.0/users/"; use strict; use warnings; use LWP::UserAgent; use HTTP::Request::Common qw{ POST }; use CGI; my $ua = LWP::UserAgent->new(); my $request = POST( $url, [ 'name' => 'mkhun', 'is_platform_access_only' => 'true',"Authorization" => "Bearer <ACC TOK>" ] ); my $content = $ua->request($request)->as_string(); my $cgi = CGI->new(); print $cgi->header(), $content; The above code always give the 400 error. And throwing the {"type

How to detect a changed webpage?

烂漫一生 提交于 2019-12-10 19:20:01
问题 In my application, I fetch webpages periodically using LWP. Is there anyway to check whether between two consecutive fetches the webpage has got changed in some respect (other than explicitly doing a comparison) ? Is there any signature(say CRC) that is being generated at lower protocol layers which can be extracted and compared against older signatures to see possible changes ? 回答1: There are two possible approaches. One is to use a digest of the page, e.g. use strict; use warnings; use

Installing a new ca certificate for Perl 5.14.2 LWP on Ubuntu 12.04

╄→гoц情女王★ 提交于 2019-12-10 03:14:43
问题 I am getting the following error trying to connect to a specific https website using LWP: LWP::Protocol::https::Socket: SSL connect attempt failed with unknown errorerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed at /usr/local/share/perl/5.14.2/LWP/Protocol/http.pm line 51. I tried with wget and got: ERROR: cannot verify [domain]'s certificate, issued by `/C=US/ST=Arizona/L=Scottsdale/O=GoDaddy.com, Inc./OU=http://certificates.godaddy.com/repository/CN=Go