Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open file on remote URL

Status
Not open for further replies.

NateBro

Programmer
Sep 1, 2004
233
US
ok, i'm trying to open a file though its URL, such as..

Code:
  open(IMG, "[URL unfurl="true"]http://www.myimg.com/myimg.gif");[/URL]

now, in reality how would i do this?

i know there is a .pm, but with my web server i can only use their stock .pm's so ya, any help would be amazing! :D
 
you could 'get' it into a variable
or you could 'getstore' it into a file

Code:
use LWP::Simple;

my $content = get("[URL unfurl="true"]http://yada.yada.com/img.gif");[/URL]
die "Couldn't get it!" unless defined $content;

Jeb
\0
 
you can't open a file thru it's URL, not sure why you think that's even possible. What are you trying to do?
 
what i'm trying to do is get the size of a web page by not only counting the file its self, but also any pictures and or flash as well.

so if i have an html page such as...
Code:
<html>
 <b>this is my text</b><br>
 <img src='extremely_large_pict.gif'>
</html>

it would count the html file size, and also the picture file size as well.

Thanks,
Nate_Bro
 
thanks guys, but the get() worked just fine! thnkx sooo much! :)
 
Nate

If this is your web site, then fine. If it's someone elses, and you intend to trawl every page off it, then be nice, otherwise they may think they are being subjected to DOS attack. I don't know if LWP::Simple checks the robots.txt file, but there are more sophisticated modules that do. See for robot etiquette.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top