Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从网页/网站查找关键字_Php_Preg Match_File Get Contents - Fatal编程技术网

Php 从网页/网站查找关键字

Php 从网页/网站查找关键字,php,preg-match,file-get-contents,Php,Preg Match,File Get Contents,我有可以从特定url/网页中找到单词的代码 $homepage = file_get_contents('http://www.example.com/furniture'); if (preg_match("/Sofa /i", "$homepage")) { echo "A match was found."; } else { echo "A match was not found."; } 我想知道的是,是否可以从整个网站www.example.com动态获取关键字“s

我有可以从特定url/网页中找到单词的代码

$homepage = file_get_contents('http://www.example.com/furniture');
if (preg_match("/Sofa /i", "$homepage")) {
    echo "A match was found.";
} else {
    echo "A match was not found.";
}

我想知道的是,是否可以从整个网站www.example.com动态获取关键字“sofa”及其相关详细信息,如类型和成本

是的,可以从网站获取数据,但由于垃圾邮件和安全问题,大多数网站不允许直接访问

  • 您可以使用Php库
  • 或者在网页中插入Javascript链接
请发布一个“类型和成本”的示例,而且,如果没有真实的示例,很难提供帮助。