繁体   English   中英

PHP 用于在 web 页面上搜索单词的脚本

[英]PHP Script to search for word on web page

如果站点http://www.stutteringjohnsmith.com有“找不到”这个词,那么有人可以告诉我如何更改以下 PHP 脚本并说“找到”

<?php
$data = file_get_contents('http://www.stutteringjohnsmmith.com/#/0');
$regex = '/Page 1 of (.+?) results/';
preg_match($regex,$data,$match);
var_dump($match);
echo $match[1];
?>
<?php
$data = file_get_contents('http://www.stutteringjohnsmmith.com/#/0');
$regex = '/standup/';    //<----
preg_match($regex,$data,$match);
var_dump($match);
echo $match[1];
?>

哈哈?

<?php
$text = file_get_contents('http://www.stutteringjohnsmith.com/#/0');
echo (stristr ($text, 'standup')) ? 'found' : 'not found';
?>

您正在使用 wordpress 域 (http://stutteringjohnsmith.wordpress.com/)

以下将起作用:

$data = file_get_contents('http://stutteringjohnsmith.wordpress.com/');
$regex = '/standup/';    

if (preg_match($regex, $data)) {
    echo "found";
} else {
    echo "not found";
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM