Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open remote file via http

Is there any perl module like File::Remote, that works over http (read only)? Something like

$magic_module->open( SCRAPE, "http://somesite.com/");
while(<SCRAPE>)
{
  #do something     
}
like image 590
d135-1r43 Avatar asked Dec 05 '25 19:12

d135-1r43


2 Answers

Yes, of course. You can use LWP::Simple:

use LWP::Simple;
my $content = get $url;

Don't forget to check if the content is not empty:

die "Can't download $url" unless defined $content;

$content will be undef it some error occurred during downloading.

like image 157
Igor Chubin Avatar answered Dec 08 '25 12:12

Igor Chubin


Also you can use File::Fetch module:

File::Fetch
    ->new(uri => 'http://google.com/robots.txt')
    ->fetch(to => \(my $file));
say($file);
like image 30
Denis Ibaev Avatar answered Dec 08 '25 12:12

Denis Ibaev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!