![](/img/trans.png)
[英]Parsing data from javascript array and combine with simple html dom
[英]Parsing with PHP Simple HTML DOM: URLs from CSV but in array just last URL from the list
尝试使用CSV网址从特定页面获取所有产品,但无法正常工作。 有三个数组:
它仅适用于$ test_base ,其他返回空数组,最后一个LINK除外。 我只是不明白,因为此LINKS数组是相同的。
include_once('simple_html_dom.php');
// Getting links array
$base = file("base.txt");
$words = array();
foreach($base AS $word) {
$words[] = $word;
}
$test_base= array("LINK_1","LINK_2","LINK_3");
// Arrays are exactly the same
print_r($test_base);
print_r($base);
print_r($words);
// Main loop for one link
foreach($test_base AS $word) {
$html = file_get_html($word);
// Getting all info for one link
foreach($html->find('div.item_info') as $article) {
$item['title'] = $article->find('.item_name', 0)->plaintext;
$item['manufacture'] = $article->find('.item_additional-info', 0)->plaintext;
$item['price'] = $article->find('.price span', 0)->plaintext;
$articles[] = $item;
}
echo "<pre>";
print_r($articles);
echo "</pre>";
$html->clear();
unset($html);
}
我已经在file()函数中添加了FILE_IGNORE_NEW_LINES参数,并在字符串末尾删除了空格。 现在一切正常。 谢谢大家!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.