我正在写一个我正在写的网络爬虫的最后一个地方。网络爬虫出现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 . ")");