![](/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.