【发布时间】:2013-05-12 09:44:04
【问题描述】:
尝试编写一个脚本,从 txt 中获取一行(行是 url),转到该 url,搜索并获取特定数据。抓取数据有效,但我需要多次这样做。这是 find and get sn -p 它工作正常。
include(dom.txt);
$html = file_get_html('url here');
foreach($html->find('a.live') as $e)
echo (''.$e->innertext.'<br />');
这是我到目前为止所做的,但我收到一个错误“警告:file_get_contents(Array)”
<?php
include ("dom.php");
$file = fopen("urls.txt", "r");
$i = 0;
while (!feof($file)) {
$line[] = fgets($file);
}
fclose($file);
foreach ($line as $x){
$html = file_get_html("$line");
foreach($html->find('a.live') as $e)
echo (''.$e->innertext.'<br />');
}
?>
有人可以帮忙吗? :(
编辑更改 $html = file_get_html("$line"); $html = file_get_html("$x");但还是报错
Edit 2 脚本有效,但我认为它会覆盖结果并且只显示最后一个结果
【问题讨论】:
标签: php while-loop line