#1
  1. No Profile Picture
    vdschoor
    Guest
    Devshed Newbie (0 - 499 posts)
    I'd like some help with writing a script that grabs part of another HTML page.

    For example :

    I want to grab the content of a HTML page that contains the following strings :

    <!-- begin --> and <!-- end -->

    Then I want to get all the content (including these two tags) that is in between the two tags.

    Could someone help me?

    Thanks,
    Iwan
  2. #2
  3. No Profile Picture
    cbolt
    Guest
    Devshed Newbie (0 - 499 posts)
    <?
    $server = "www.whatever.com";
    $file = "/path/to/file.html";
    $fp = fsockopen($server, 80, &$errno, &$errstr);
    if ($fp) {
    fputs($fp,"GET $file HTTP/1.0nHost: $servernn");
    $getit = false;
    while ($line = fgets($fp, 4096)) {
    if (eregi("<!-- begin -->", $line)) {
    $getit = true;
    }
    elseif (eregi("<!-- end -->", $line)) {
    $getit = false;
    }
    if ($getit == true) {
    $lines[] = $line;
    }
    }
    fclose($fp);
    }
    ?>

    A bit of a kludge, but it works (I hope :-)
  4. #3
  5. No Profile Picture
    vdschoor
    Guest
    Devshed Newbie (0 - 499 posts)
    Thanks a lot!

    It works perfectly, exactly what I needed!

    Iwan

Similar Threads

  1. header/footer in html (each page) just like word file
    By nihaarika2002 in forum HTML Programming
    Replies: 4
    Last Post: April 12th, 2004, 12:51 PM
  2. 2 part OUTPUT HTML
    By tiger_1234 in forum Perl Programming
    Replies: 3
    Last Post: February 10th, 2004, 04:15 PM
  3. Replies: 0
    Last Post: February 8th, 2004, 10:11 PM
  4. html 2 buttons on a page.
    By hussaim4 in forum HTML Programming
    Replies: 6
    Last Post: January 30th, 2004, 04:09 PM
  5. need to search an html page in html
    By lwaa in forum HTML Programming
    Replies: 8
    Last Post: January 23rd, 2004, 09:07 PM

IMN logo majestic logo threadwatch logo seochat tools logo