CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
reading in a file at a URL

 



Mel
Deleted

Jun 11, 2000, 11:45 AM

Post #1 of 7 (798 views)
reading in a file at a URL Can't Post

How can you tell a script to open a URL and read in it's html source in to an array. For example, the programs where you type in a url and it displays the page with things changed, such as in translation programs.


dws
Deleted

Jun 11, 2000, 1:16 PM

Post #2 of 7 (798 views)
Re: reading in a file at a URL [In reply to] Can't Post

use LWP::Simple;

$html = get("http://www.perlguru.com/");




Cure
User

Jun 11, 2000, 1:32 PM

Post #3 of 7 (798 views)
Re: reading in a file at a URL [In reply to] Can't Post

use LWP::Simple;
getprint('http://www.cureable.com');

Cure


Mel
Deleted

Jun 11, 2000, 3:31 PM

Post #4 of 7 (798 views)
Re: reading in a file at a URL [In reply to] Can't Post

Thanks a bunch.

Now It does what I want it to but all images on the page come up broaken and the links are messed up. Is there a ways to fix this so that the images and links will come out just as if you were actually visiting the site? Like putting the url in front of the the file or image name or something in the html so it will come out right.
I really appreciate your help on this.


Cure
User

Jun 11, 2000, 4:44 PM

Post #5 of 7 (798 views)
Re: reading in a file at a URL [In reply to] Can't Post

you need to use a regex

Example of the Simple module and a regex to fetch a website and to make the images display.


use LWP::Simple;
print "Content-type: text/html\n\n";
my $url ='http://www.hyperdesign.net';
$_=get($url);
s!(images)!$url/$1!g and print;


Cure



Mel
Deleted

Jun 11, 2000, 4:53 PM

Post #6 of 7 (798 views)
Re: reading in a file at a URL [In reply to] Can't Post

It did not work, it still displays the page with broaken images.


Cure
User

Jun 11, 2000, 7:38 PM

Post #7 of 7 (798 views)
Re: reading in a file at a URL [In reply to] Can't Post

The one I showed you DOES WORK for that particualr case.

YOU NEED TO LEARN REGEX

perldoc perlre


Cure

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives