SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Seattle, WA area
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd like to know how I can open a remote web site and see if a certain string of text is present on the site. How would I accomplish this? Would I use ereg or something similar?

    Thanks.

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to use sockets. I don't know how to do this myself. In fact I was reading a tutorial on TCP sockets in PHP last night. There are others here who know how though.

  3. #3
    SitePoint Member WingMan's Avatar
    Join Date
    Feb 2001
    Location
    Cape Town, South Africa
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    file function; then strstr function

    in the php documentation the file funtion:

    PHP Code:
    <?php
    // get a web page into an array and print it out
    $fcontents file ('http://www.php.net');
    while (list (
    $line_num$line) = each ($fcontents)) {
        echo 
    "<b>Line $line_num:</b> " htmlspecialchars ($line) . "<br>\n";
    }

    // get a web page into a string
    $fcontents join (''file ('http://www.php.net'));
    ?>
    The whole page then gets put in an array, each line an array item.

    Then you loop throught the array and use the strstr function. (again, see documentation for use).

    The strstr function returns false if the string is not found, so you loop through the array untill you get a true.

    Msg me if you need more info.

    p.s. One of the techs I work with used this function to generate a dial-in POP list from our internet access provider web site. We then displayed the list for out customers on our website.
    Last edited by WingMan; Mar 31, 2001 at 06:26.


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
  •