0

我有 txt 中的 http 列表分别由 \n 我想通过 php curl 每个页面并搜索指定字符串

具体的字符串是:

http://www.....com/xyz/...png or .gif


$ch = curl_init("ARRAY of page from txt????");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$text = curl_exec($ch);
$test = strpos($text, "HOW CREATE THE SPECIFIC STRING???");
if ($test==false)
{
    echo $test;
}
else
{
    echo "no exist";
}
4

2 回答 2

1
<?
$array = explode("\n", file_get_contents('fileName.txt'));

foreach($array as $url){

         $ch = curl_init(); 

        // set url 
        curl_setopt($ch, CURLOPT_URL, "example.com"); 

        //return the transfer as a string 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

        // $output contains the output string 
        $output = curl_exec($ch); 

        // close curl resource to free up system resources 
        curl_close($ch); 

        $result[] = $output;  

}
?>

finally 数组 $result 包含文本文件中链接的所有 html

于 2013-10-23T22:25:25.673 回答
0

对 url 做一个爆炸,例如: $urls = explode ('\n', urlstring)

现在您可以遍历 url 数组。

于 2013-10-23T22:18:28.750 回答