2008-11-09 45 views

回答

6

只要阅读页面内容,就像阅读文件一样。 PHP为你做连接的东西。然后通过正则表达式或简单字符串比较来查找字符串。

$url = 'http://my.url.com/'; 
$data = file_get_contents($url); 

if (strpos('maybe baby love you', $data) === false) 
{ 

    // do something 

} 
+2

这应该是“strpos($ data, '也许宝宝爱你');“ [strpos](http://php.net/manual/en/function.strpos.php) – moteutsch 2011-05-24 21:41:43

0

假设的fopen URL封装上...

​​
0

如果未启用的fopen URL封装,您可以使用卷曲模块(见http://www.php.net/curl

也卷曲让您能够处理已验证的页面,重定向等。

5
//The Answer No 3 Is good But a small Mistake in the function strpos() I have correction the code bellow. 

$url = 'http://my.url.com/'; 
$data = file_get_contents($url); 

if (strpos($data,'maybe baby love you') === false) 
{ 
    // do something 
}