SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2003
    Location
    USA
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    lwp equivalent for PHP

    I tried searching for this in the PHP forums, but didn't not find anything.

    I'm looking to see if there is a PHP equivalent to the LWP::simple Perl module. Below is a Perl snip of code that I've been using. It just grabs a file from another server and temporarily stores it on the originating server for processing. PHP can do something like this? Thanks!

    my $f1 = "https://www.moo.cow/$file".".html";
    my $f2 = "https://www.moo.cow/html/$file"."_sidemenu.html";
    my $f3 = "https://www.moo.cow/html/titles.html";
    my $tmpfile = "tmp/".$file."$active_userid";
    my $tfile = "tmp/titles.html";
    my $line = "";
    my @item = ();

    $content = get($f1);
    getstore($f2,$tmpfile);
    getstore($f3,$tfile);

    open (FILEHANDLE,$tmpfile) or die "$f1";
    while(<FILEHANDLE>)
    {
    $line = $_; chomp($line);
    $line =~ s/^\s+//; $line =~ s/\s+$//;
    @item = split(/,/,$line); push(@links,[@item]);
    }
    close(FILEHANDLE);

    unlink($tmpfile);

  2. #2
    No. Phil.Roberts's Avatar
    Join Date
    May 2001
    Location
    Nottingham, UK
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use URL's in the file handling functions in recent versions of PHP.

    Something like:

    PHP Code:
    $data file('http://www.mysie.com/file.html');

    $fp fopen("./tempfile.tmp""w+");
    foreach(
    $data as $line) {
        
    fputs($fp$line);
    }
    fclose($fp); 

  3. #3
    SitePoint Member
    Join Date
    Jun 2003
    Location
    USA
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you

    Quote Originally Posted by Phil.Roberts
    You can use URL's in the file handling functions in recent versions of PHP.

    Something like:

    PHP Code:
    $data file('http://www.mysie.com/file.html');

    $fp fopen("./tempfile.tmp""w+");
    foreach(
    $data as $line) {
        
    fputs($fp$line);
    }
    fclose($fp); 


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •