我有一个带有5000行的URL的txt文件。我试图做的是打开每个网址来提取每个网址(即第一个网址)。 我的问题是,脚本的第一行打开URL并告诉我有多少链接没有问题。但对于URL的文件中其余的心不是显示什么...数组显示是这样的:阅读URL和解析信息
Array
(
)
Array
(
)
我的代码:
$homepage = file_get_contents('***mytxt file****');
$pathComponents = explode(",", trim($homepage)); //line breaker
//echo "<pre>";print_r($pathComponents);echo "</pre>";
$count_nlines = count($pathComponents);
for ($i=0;$i<3;$i++) {
$request_url = $pathComponents[$i];
//echo $request_url . "<br>";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url); // The url to get links from
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // We want to get the respone
$result = curl_exec($ch);
$regex='|<a.*?href="(.*?)"|';
preg_match_all($regex,$result,$parts);
$links=$parts[1];
echo "<pre>";print_r($links);echo "</pre>";
curl_close($ch);
}
任何想法?
你有你的数组文件的例子吗? –
你的意思是我收到的第一个数组? – subversive
没有你的.txt文件中的数组。 –