Jump to content

help me, how to find text on an external html site using PHP


syam92

Recommended Posts

Would anyone know how to search an external html file for a work or phrase ?

 

I was thinking something like this --

I use script cURL...

 

<?php
if (isset($_POST['submitted'])) {

    $xurl_1 = $_POST['url_1'];
    $xtext_1 = $_POST['text_1'];

    function check_1($url_1, $text_1){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$url_1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        $result=curl_exec ($ch);
        curl_close ($ch);
        
        preg_match ("|<[pP]>".$text_1."<\/[pP]>|i", $result, $matches);
        
        if (count($matches)>0){
            $i=true;
        }else{
            $i=false;
        }
        return $i;
    }
    
    if(check_1( $xurl_1, $xtext_1)){
        echo "Text found";
    }else{
        echo "Text not found";
    }

} else {
?>

      <h3>Link Verifier</h3>
      <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
      <p><b>URL :</b> <input type="text" name="url_1" size="30" value="" /></p>
      <p><b> Exist :</b> <input type="text" name="text_1" size="30" value="" /></p>
      <div align="center"><input type="submit" name="submit" value="Check" /></div>
      <input type="hidden" name="submitted" value="TRUE" />
      </form>
      <?php
      }
      ?>

 

Unfortunently, that doesn't work..

 

it say:

"Fatal error: Call to undefined function curl_init() in /home/*/*/new.php on line 8"

 

how to install cURL on windows?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.