Results 1 to 5 of 5

Thread: [RESOLVED] Grab and display HTML from between two points

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    50

    Resolved [RESOLVED] Grab and display HTML from between two points

    Hi All, long time!!

    Basicly, what I am wanting todo is grab a section of HTML of one webpage (lets say...www.fruit.com/grape.html).
    And then use that HTML on a local webpage on my server (lets say www.pie.com/steak.php).


    I want it to use the HTML, which has been fetched from between two specified points.

    So the points lets say are ("<table class="pips">") and will stop grabbing the html at ("</table>")

    I hope this makes sense....Im some what tired lol


    Please ask any questions if you do not understand me.

    Thanks,
    Samm

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Grab and display HTML from between two points

    I do not understand why you need to do this. I assume you have permission from the copyright owner to do this too.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    50

    Re: Grab and display HTML from between two points

    From a friends website, to my website . And yes, permission granted

  4. #4
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Grab and display HTML from between two points

    you can use file_get_contents() to grab a page's contents. then, you can use strpos() and substr() to get the information you'd like.
    PHP Code:
    <?php
      $content 
    file_get_contents("http://apple.com/pie.htm");

      
    //where we should start and end
      
    $start "<table class=\"pips\">";
      
    $end "</table>";
      
      
    $st_pos strpos($content$start) + strlen($start);  //starting position
      
    $en_pos strpos($content$end);  //end position

      
    $content substr($content$st_pos$en_pos $st_pos);

      echo 
    $content;
    ?>

  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    50

    Re: Grab and display HTML from between two points

    Works a treat, thankyou!

Posting Permissions

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



Click Here to Expand Forum to Full Width