PHP Word Finding....

Discussion in 'PHP' started by Arson, Dec 3, 2007.

  1. #1
    I am wondering if there is any kind of command in PHP that will search a web page for a certain word, and then confirm whether or not the word was found.

    For example, say I wanted to find the word "ebay" on www.ebay.com, the script would look for it, and then it would come back and tell me, yes, the word ebay is on www.ebay.com!

    Or, if I wanted to find the word "Microsoft" on a linux enthusiast website, it would search the site, and come back and tell me hey, the word "microsoft" was not found on that linux enthusiast site..

    So, is there any special command or whatnot that would allow me to do this?
     
    Arson, Dec 3, 2007 IP
  2. Arson

    Arson Well-Known Member

    Messages:
    622
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    120
    #2
    Ok I have figured out that its cURL. And there is a way to do it so the site thinks its a google bot.

    I am willing to hire someone to make me a script like what I described in my first post, using cURL
     
    Arson, Dec 3, 2007 IP
  3. ognos

    ognos Peon

    Messages:
    26
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    use also preg_match_all

    f.e. preg_match_all('/(\d+)/', $page, $wynik );

    just change (\d+) <- this is for numbers

    and then if $wynik[0][$n] ($n++) is equal to ebay
     
    ognos, Dec 4, 2007 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    No need for preg_match_all() and looping.

    Here's an example:
    
    
    $url = 'http://www.ebay.com';
    $query = 'ebay';
    $case_insensitive = true;
    
    
    if ($source = @file_get_contents($url))
    {
        if (preg_match(sprintf('~%s~%s', preg_quote($query, '~'), $case_insensitive ? 'i' : ''), $source))
        {
            echo 'Found';
        }
        else
        {
            echo 'Not found';
        }
    }
    
    PHP:
     
    nico_swd, Dec 4, 2007 IP
  5. Arson

    Arson Well-Known Member

    Messages:
    622
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    120
    #5
    Thanks :) :)
     
    Arson, Dec 4, 2007 IP