Current location: Hot Scripts Forums » Programming Languages » PHP » Use PHP to download .html file from another site (Like LWP::Simple in Perl) ?


Use PHP to download .html file from another site (Like LWP::Simple in Perl) ?

Reply
  #1 (permalink)  
Old 07-01-03, 12:20 PM
kevin kevin is offline
Newbie Coder
 
Join Date: Jun 2003
Location: USA
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Use PHP to download .html file from another site (Like LWP::Simple in Perl) ?

HI !

HOw to use PHP to download a .html file? Look like the Perl module LWP::Simple?

Thanks a lot !

Kevin
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-01-03, 01:24 PM
jv2222 jv2222 is offline
The Freshmaker
 
Join Date: Jun 2003
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Code:
$fp = fopen ("http://www.example.com/", "r");

while (!feof ($fp)) 
{
    $buffer = fgets($fp, 4096);
    echo $buffer;
}

fclose ($fp);
Cheers,
Justin
__________________
Author of <a href=http://www.hotscripts.com/Detailed/18290.html target=_blank>ezSQL</a> (makes life soooo easy when working with databases)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-01-03, 04:22 PM
kevin kevin is offline
Newbie Coder
 
Join Date: Jun 2003
Location: USA
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Jv !

How come I got the error message (see below)


Warning: fopen("http://www.example.com/", "r") - No such file or directory in /home/kevin/public_html/getfile.php on line 3


It seems that fopen works only if I open a file with full path

fopen("/home/kevin/public_html/index.html","r")

Just don't know why ! DO you have any idea ?

Kev
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 07-01-03, 06:19 PM
jv2222 jv2222 is offline
The Freshmaker
 
Join Date: Jun 2003
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Perhpas it is not enabled on your server?
__________________
Author of <a href=http://www.hotscripts.com/Detailed/18290.html target=_blank>ezSQL</a> (makes life soooo easy when working with databases)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 07-03-03, 02:57 AM
Chris Boulton Chris Boulton is offline
Wannabe Coder
 
Join Date: Jun 2003
Location: Sydney, Australia
Posts: 208
Thanks: 0
Thanked 0 Times in 0 Posts
I think you have to specify the full url..

You could try this as well..

PHP Code:

<?php

$arr 
file("http://www.hotscripts.com");
$contents implode(""$arr);
?>
$arr is an array consisting of each line in the file..
$contents is it all imploded together as one variable.
__________________
Chris Boulton
SurfiOnline!
MyBulletinBoard
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP code to edit a text file mdhall Script Requests 12 12-23-10 05:03 AM
one-page form/catalog in php, data fed in with .csv file? domaky PHP 2 10-25-03 10:32 AM
file download problem ukyankee Perl 6 10-04-03 11:39 PM
PHP and TXT file Vyrus PHP 10 07-13-03 12:05 PM
Free PHP, Perl and possible mySQL hosting! toby General Advertisements 8 06-17-03 02:04 AM


All times are GMT -5. The time now is 10:51 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.