Home > Backend Development > PHP Tutorial > PHP uses curl to crawl Sina Weibo content example_PHP tutorial

PHP uses curl to crawl Sina Weibo content example_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:31:45
Original
1050 people have browsed it

Many people like to DIY their own Weibo on the website, so I also wrote one.
The Weibo show address in Sina Weibo tool is directly captured here.

Copy code The code is as follows:

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"; // Weibo show address
$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('/

(.*) preg_match_all('/(.*)/iUs',$content,$ time);//Get time
$me=explode('

',$content);
$me=explode('
',$me [1]);
preg_match_all("/src="([^"].*)"/iUs",$me[0],$avatar);//Get my avatar

$a=$text[0];
$b=$time[0];
$result=array_combine($a, $b);//Combine arrays
foreach($result as $text=>$time){
echo "";
echo strip_tags( $text);
echo strip_tags($time);
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/761666.htmlTechArticleMany people like to DIY their own Weibo on the website, so I also wrote one. Here we directly capture the Weibo show address in Sina Weibo tool. Copy the code The code is as follows: ?php set_t...
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template