i漂泊

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 4258|回复: 0

通过CURL来获取新浪微博的内容

[复制链接]
TA的礼物信息
  • 收到:0
  • 送出:2
发表于 2014-5-5 16:43:12 | 显示全部楼层 |阅读模式
  1. <?php
  2.   set_time_limit(0);
  3.   $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"; //微博秀地址
  4.   $ch=curl_init();
  5.   curl_setopt($ch,CURLOPT_HEADER,false);
  6.   curl_setopt($ch,CURLOPT_URL,$url);
  7.   curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  8.   $content=curl_exec($ch);
  9.   curl_close($ch);
  10.   preg_match_all('/<p class="weiboShow_mainFeed_listContent_txt">(.*)<\/p>/iUs',$content,$text);//获取文字
  11.   preg_match_all('/<span class="weiboShow_mainFeed_listContent_actionTime">(.*)<\/span>/iUs',$content,$time);//获取时间
  12.   $me=explode('<div class="weiboShow_developer_pic">',$content);
  13.   $me=explode('</div>',$me[1]);
  14.   preg_match_all("/src="([^"].*)"/iUs",$me[0],$avatar);//获取我的头像

  15.   $a=$text[0];
  16.   $b=$time[0];
  17.   $result=array_combine($a, $b);//合并数组
  18.   foreach($result as $text=>$time){
  19.     echo "<img src='".$avatar[1][0]."' height='50'/>";
  20.     echo strip_tags($text);
  21.     echo strip_tags($time);
  22.   }
  23. ?>
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|IPiaoBo Inc. ( 渝ICP备17002826号 )

GMT+8, 2024-4-19 15:08 , Processed in 0.080252 second(s), 46 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表