小编Imr*_*him的帖子

CURL 停止工作

我想从列表中搜索一些关于某个单词的链接。所以我正在制作一个脚本:

//html code here.
<?
if (array_key_exists('form_action', $_POST)){
$pel=$_POST['url'];
$toplist=file_get_contents($pel);
$listgrabbing=explode("\r\n",$toplist);
foreach($listgrabbing as $item)
{    

$useragent="Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; Alexa Toolbar; .NET CLR 2.0.50727)";
$urlto=$item;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $urlto);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_COOKIEJAR, "COOKIE.txt"); 
curl_setopt($ch, CURLOPT_COOKIEFILE, "COOKIE.txt"); 
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10); 
$buffer = curl_exec($ch);
$po = strpos($buffer,"article");
if ($po===false)
{
echo ($item."---Word didn't found!");
echo "<br>";
}
else {
echo ($item."---Word Found!");
echo "<br>";
}
}
} …
Run Code Online (Sandbox Code Playgroud)

php curl

5
推荐指数
1
解决办法
2154
查看次数

标签 统计

curl ×1

php ×1