php抓取新浪微博数据抓取,php利用curl抓取新浪微博内容示例

很多人都喜欢在网站上DIY自己的微博,所以我也写了一个。

这里直接抓取了新浪微博工具中的微博秀地址。

set_time_limit(0);

$url="http://widget.weibo.com/weiboshow/index.php?language=&width=0&height=550&fansRow=2&ptype=1&speed=0&skin=1&isTitle=1&noborder=1&isWeibo=1&isFans=1&uid=1724077823&verifier=8738a0fa&dpc=1"; //微博秀地址

$ch=curl_init();

curl_setopt($ch,CURLOPT_HEADER,false);

curl_setopt($ch,CURLOPT_URL,$url);

curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

$content=curl_exec($ch);

curl_close($ch);

preg_match_all('/

(.*)/iUs',$content,$text);//获取文字

preg_match_all('/(.*)/iUs',$content,$time);//获取时间

$me=explode('

',$content);

$me=explode('

',$me[1]);

preg_match_all("/src=\"([^\"].*)\"/iUs",$me[0],$avatar);//获取我的头像

$a=$text[0];

$b=$time[0];

$result=array_combine($a, $b);//合并数组

foreach($result as $text=>$time){

    echo "%22.%24avatar%5B1%5D%5B0%5D.%22";

echo strip_tags($text);

echo strip_tags($time);

}

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值