时间:2021-07-01 10:21:17 帮助过:2人阅读
function makePage($link)
{
......
//当网址属于xuegong.hubu
else if(strstr($link, 'xuegong.hubu'))
{
$page = curl_init();
curl_setopt($page, CURLOPT_URL , $link);
curl_setopt($page, CURLOPT_RETURNTRANSFER , 1);
$content = curl_exec($page);
$content = stristr($content, 'class="title"');
$content = stristr($content, 'class="bottom"', true);
$content = str_replace('class="title">', '', $content);
$content = strip_tags($content,'');
$content = stristr($content, '责任编辑',true);
$content = trim($content);
$content = str_replace("\r\n", "
", $content);
$content = preg_replace('/(
){2,}/', '
', $content);
$content = str_replace('href="', 'href="http://xuegong.hubu.edu.cn', $content);
return $content;
}
}
$content = mysql_real_escape_string(makePage($notice[1][$key]));
$sql = 'insert ignore into php_notice(title,link,date,content) values("'.$value.'","'.$notice[1][$key].'","'.$notice[2][$key].'","'.$content.'");';
mysql_query($sql) or die(mysql_error());
我是把项目放在sae上面,数据库都连接了,抓取其他网页的内容写入数据库都没问题,但是碰到xuegong的网页写入数据库在PHPMyAdmin查看是空格,
PHP也没有提示错误,而且将内容打印出来也是对的,就是写入数据库之后变成了空格,编码都是utf-8。不知何解,求教