我正在寫一個我正在寫的網絡爬蟲的最後一個地方。網絡爬蟲出現Implode錯誤
網絡爬蟲爬行英國廣播公司新聞,然後插入鏈接到數據庫連同標題和描述等所有的工作,但我有一個數組與所有的啓動網址,以便只有任何開始的鏈接只是插入。
我正在使用foreach循環所有鏈接數組的所有數組變量,並檢查它們是否符合條件,插入到新數組中,然後將其插入到一個字符串中,然後插入到mysql數據庫中。
但是,關於我的內爆功能出現錯誤。我被卡住了。
$bbc_values = array('http://www.bbc.co.uk/news/health-', 'http://www.bbc.co.uk/news/politics-', 'http://www.bbc.co.uk/news/uk-', 'http://www.bbc.co.uk/news/technology-', 'http://www.bbc.co.uk/news/world-', 'http://www.bbc.co.uk/news/england-', 'http://www.bbc.co.uk/news/northern_ireland-', 'http://www.bbc.co.uk/news/scotland-', 'http://www.bbc.co.uk/news/wales-', 'http://www.bbc.co.uk/news/business-', 'http://www.bbc.co.uk/news/education-', 'http://www.bbc.co.uk/news/science_and_enviroment-', 'http://www.bbc.co.uk/news/entertainment_and_arts-', 'http://edition.cnn.com/');
foreach ($links as $link) {
$output = array(
"title" => Titles($link), //dont know what Titles is, variable or string?
"description" => getMetas($link),
"keywords" => getKeywords($link),
"link" => $link
);
if (empty($output["description"])) {
$output["description"] = getWord($link);
}
foreach ($output as $new_array) {
if (in_array($new_array['link'], $bbc_values)) {
$news_stories[] = $new_array;
}
}
$data = '"' . implode('" , "', $news_stories) . '"';
$result = mysql_query("INSERT INTO news_story (`title`, `description`, `keywords`, `link`) VALUES (" . $data . ")");