通过curl检查url,如果找到单词/文本,就做点什么


Check url via curl, and if word/text is found do something


我四处寻找一个类/函数/php脚本,该脚本通过cURL检查在获取中是否找到文本、单词或html代码,如果响应为真,请采取措施;如果为false,请执行其他操作。为了更清楚,

if is found [You need to login]
do redirect:login.php
if is not found
do redirect:showList.php


希望我清楚易懂,希望有人能帮助我。
非常感谢。

这是一种方法。不过它不使用curl。

$page = file_get_contents("http://www.example.com/page.html");
$search = strpos("$page", "the text we want");
if ($search !== false) {
    header("Location: http://www.example.com/login.php");
    die();
} else {
    header("Location: http://www.example.com/showList.php");
    die();
}
相关文章: