PHP-如何查看单词是否在特定网页上?

问题描述 投票:0回答:1

我需要检查网站外部的网页上是否有特定的单词。我已经尝试过file_get_contents(),但是它没有返回任何内容。有什么办法可以用PHP做到这一点?

编辑:这是我尝试过的:

$query = 'example';
$file = "https:// www.site.com/search?q=$query";
// tested url and it works, had to add space to post it
$contents = file_get_contents($file);
echo $contents;

我原以为它会输出整个页面供以后使用.includes(),但它什么都不输出。

php string search substring file-get-contents
1个回答
0
投票

查看curl以获取网页的内容。然后,您可以使用preg_match查找单词。

© www.soinside.com 2019 - 2024. All rights reserved.