我的代码:
<?
$urls = file('urls.txt');
$error = fopen('error.txt','w');
$find1 = 'sometext';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; Googlebot/2.1; http://www.google.com/bot.html)');
foreach($urls as $url) {
curl_setopt($ch, CURLOPT_URL, $url);
$out = curl_exec($ch);
$pos = strpos($out, $find1);
echo $out;
if ($pos === false) {
fwrite($error,$url); }
}
fclose($error);
?>
我在urls.txt中有网址列表,我需要检查这些网址在代码中是否有“sometext”。如果没有'sometext',我需要将此url写入error.txt。我的代码中的错误在哪里?