lwp

Suppressing "Day too big" warning in Perl LWP::UserAgent

I have a fairly simple perl script with uses the LWP::UserAgent module to follow URLs through redirection to find the final destination URL which it then stores in our MySQL database. The problem is that from time to time the script reports warnings that look like this: Day too big - 25592 > 24855 Sec too small - 25592 < 74752 Sec too ...

How do I enable IPv6 support in LWP?

The following code ... my $user_agent = LWP::UserAgent->new; my $request = HTTP::Request->new(GET => $url); my $response = $user_agent->request($request); if ($response->is_success) { print "OK\n"; } else { die($response->status_line); } .. will fail with .. 500 Can't connect to <hostname> (Bad hostname '<hostname>') .. if ...

Why does Perl's LWP gives me a different encoding than the original website?

Hey, Lets say i have this code: use strict; use LWP qw ( get ); my $content = get ( "http://www.msn.co.il" ); print STDERR $content; The error log shows something like "\xd7\x9c\xd7\x94\xd7\x93\xd7\xa4\xd7\xa1\xd7\x94" which i'm guessing it's utf-16 ? The website's encoding is with <META HTTP-EQUIV="Content-Type" CONTENT="text/h...

How do I process the response as a file without using the :content_file option?

Example code: my $ua = LWP::UserAgent->new; my $response = $ua->get('http://example.com/file.zip'); if ($response->is_success) { # get the filehandle for $response->content # and process the data } else { die $response->status_line } I need to open the content as a file without prior saving it to the disk. How would you do ...

How can I get the ultimate URL without fetching the pages using Perl and LWP?

I'm doing some web scraping using Perl's LWP. I need to process a set of URLs, some of which may redirect (1 or more times). How can I get ultimate URL with all redirects resolved, using HEAD method? ...

How do I make a progress bar using Term::ProgressBar with LWP::UserAgent's post method?

#!/usr/bin/perl use LWP::UserAgent; use HTTP::Request::Common; use HTML::TreeBuilder; use Cwd 'realpath'; use warnings; use strict; my $ua = LWP::UserAgent->new(); my $response = $ua->request( POST 'http://mydomain.com/upload.php', 'Content-Type' => 'multipart/form-data', 'Content' => [...

Why does my REST request return garbage data?

I am trying to use LWP::Simple to make a GET request to a REST service. Here's the simple code: use LWP::Simple; $uri = "http://api.stackoverflow.com/0.8/questions/tagged/php"; $jsonresponse= get $uri; print $jsonresponse; On my local machine, running Ubuntu 10.4, and Perl version 5.10.1: farhan@farhan-lnx:~$ perl --version This...

perl Client-SSL-Warning: Peer certificate not verified

I am having trouble with a perl screenscraper to an HTTPS site. In debugging, I ran the following: print $res->headers_as_string; and in the output, I have the following line: Client-SSL-Warning: Peer certificate not verified Is there a way I can auto-accept this certificate, or is that not the problem? #!/usr/bin/perl use LWP::...

Reading Web 2.0 HTML Source Code with Perl

Is it possible to read HTML Web 2.0 Source Code that is dynamically generated ? The Perl LWP with its agent->response does not pick up any dynamically generated HTML code. Many websites today are generating dynamic html. If I am shoppping for best prices, and the prices are dynamically fetched and dumped, then I am out of business. Are...

Inspecting SSL cert returned via LWP request

I'm requesting a web page using LWP in perl, and I'd like to be able to access the SSL certificate that the web server presents (I'm looking for an expiration date in the cert, among other things). The information I want isn't in the three headers that Crypt::SSLeay adds to the request. Is there a way that I'm overlooking with which I ...

How do I check whether `lwp-download` worked correctly?

Hey. I don't know anything about Perl but I urgently need to modify a Perl script. At some point it's downloading an about 500MB file from a server using system("lwp-download $HttpPath $Out");. Is there any way I can find out if the downloading process went correctly, e.g. check whether downloaded file has the same size as the original...

Perl equivalent of PHP's get_file_contents() ?

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_conten...

Using Different Outbound IPs in Perl

We have a few different websites running on the same server that all access 1 particular web service with each having their own unique API key. Unfortunately the web service has a daily limit based on IP address (not API key) so while each of our sites is way under their daily limit, combined they are over the IP limit. When accessed via...

How can I access Closure JavaScript minifier using Perl's LWP::UserAgent?

Hi. I'm trying to get Code Closure to work, but unfortunately, there's always an error thrown. Here's the code: use LWP::UserAgent; use HTTP::Request::Common; use HTTP::Response; my $name = 'test.js'; my $agent = new LWP::UserAgent(); $agent->agent("curl/7.21.0 (x86_64-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1....

How to check if downloaded file using getstore() function is not complete/corrupted?

Hello, I wrote a quick script to download files using LWP::Simple library and its getstore() function. It is working rather well, but occasionally downloaded file is not complete. I do not know what is causing this, but when I download it afterward manually using wget in command line file is OK. I would guess corrupted files are caus...

How can I update my Twitter status with Perl and only LWP::UserAgent?

I'm trying to update my status through the Twitter API and OAuth. I get stuck on the last step, the status update. Here's my code. The header: $ua->default_header('Content-Type' => "application/x-www-form-urlencoded"); $ua->default_header('oauth_signature' => "$signature"); $ua->default_header('Authorization' => '"OAuth realm="Twitter...

How do I send POST data with LWP?

I want to make a program that communicates with http://www.md5crack.com/crackmd5.php. My goal is to send the site a hash (md5) and hopefully the site will be able to crack it. After, I would like to display the plaintext of the hash. My problem is sending the data to the site. I looked up articles about using LWP however I am still lost....

fetch pages [LWP] parse them [HTML::TokeParser] and store results [DBI]

Hello good evening dear stackoverflow-friends, A triple job: i have to do a job with tree task. we have three tasks: Fetch pages Parse HTML Store data... And yes - this is a true Perl-job! i have to do a parser-job on all 6000 sub-pages of a site in suisse. (a governmental site - which has very good servers ). see http://www.e...

How can I extract non-standard HTTP headers using Perl's LWP?

I'm working with a web application that sends some non-standard HTTP headers in its response to a login request. The header in question is: SSO_STATUS: LoginFailed I tried to extract it with LWP::Response as $response->header('SSO_STATUS') but it does not work. It does work for standard headers such as Set-Cookie, Expires etc. Is th...