织梦批量导入关键字技巧
1,在dede根目录下新建关键字列表txt—> key.txt,内容格式如下:
关键字1|链接网址1
关键字2|链接网址2
关键字3|链接网址3
关键字4|链接网址4
2,在dede根目录下新建 update_keyword.php,内容如下:
$sql = ” truncate table `dede_keywords` “; //注意:此处删除表,如果只是追加关键字,请注释此处
if(!$dsql->ExecuteNoneQuery($sql)) echo “错误!
“;
$convertedrows = 0;
$m_file = “key.txt”;
//读取key.txt
$fp = fopen($m_file,’r’);
$allkey = fread($fp,filesize($m_file));
$allkeys = explode(”
”, $allkey);
fclose($fp);
//print_r($allkeys);
foreach($allkeys as $keys)
{
$newkey = explode(‘|’, $keys);
$keyword = trim($newkey[‘0’]);
$rpurl = trim($newkey[‘1’]);
$rank = trim($newkey[‘2’]);
//echo $keyword.”–“.$rpurl.”–“.$rank;
//exit;
$query = “INSERT INTO `51_keywords`(keyword, rank, sta, rpurl) VALUES (‘$keyword’, ‘$rank’, ‘1’, ‘$rpurl’)”;
if(!$dsql->ExecuteNoneQuery($query)) echo “插入错误!
“;
$convertedrows ++;
echo ‘插入第’.$convertedrows.’个关键字—>’.$keyword.’
‘;
}
echo ‘共插入’.$convertedrows.’个关键字’;
exit();
?>
☉本站提供的源码、模板、软件工具等其他资源,都不包含技术服务,请大家谅解!
pbootcms模板网 » 织梦批量导入关键字技巧