我有一个 php 脚本正在运行并使用 cURL 来检索我想检查是否存在某些文本的网页内容。
现在它看起来像这样:
for( $i = 0; $i < $num_target; $i++ ) {
$ch = curl_init();
$timeout = 10;
curl_setopt ($ch, CURLOPT_URL,$target[$i]);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_FORBID_REUSE, true);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$url = curl_exec ($ch);
curl_close($ch);
if (preg_match($text,$url,$match)) {
$match[$i] = $match;
echo "text" . $text . " found in URL: " . $url . ": " . $match .;
} else {
$match[$i] = $match;
echo "text" . $text . " not found in URL: " . $url . ": no match";
}
}
我想知道是否可以使用一种特殊的 cURL 设置来使其更快(我在 php 手册中选择了对我来说似乎最好的选项,但我可能忽略了一些可以提高脚本速度和性能的选项)。
然后我想知道使用 cgi、Perl 或 python(或其他解决方案)是否会比 php 更快。
提前感谢您的任何帮助/建议/建议。