AI编程助手
AI免费问答

获取新浪微博的微博秀内容存入数据表中

PHP中文网   2016-05-25 17:04   1397浏览 原创
function BlogRequest($line){
	$line=str_replace("&",'&',$line);
	if(empty($line)){
		return false;
	}else{
		$subject = file_get_contents(trim($line));
		$regex = "/(([^]+))/ism";
		preg_match_all($regex,$subject,$blogArray);
		$i=3;
		$sqlValue=array();
		foreach($blogArray[0] as $k=>$v){
			$sqlValue[]=explode('',$blogArray[0][$i]);
			$i++;
		}
		foreach($sqlValue as $k=>$v){
			foreach($v as $key=>$value){
				$changeStr=$value;//内容不变真接存入数组
				if($key==1){//图片只需地址
					$changeStr=strip_tags(str_replace("alt=",'',preg_replace("/@@##@@0){
						$oldmin=str_replace('分钟前','',trim(str_replace('>','',str_replace('"','',strip_tags($changeStr)))));
						$nowmin=date('i',time());
						$nowHore=date('H',time());
						if($oldmin>$nowmin){
							$fmin=$nowmin+60-$oldmin;
							$nowHore=$nowHore-1;
							$changeStr=date('Y-m-d ',time()).$nowHore.":".$fmin;
						}else{
							$fmin=$nowmin-$oldmin;
							$changeStr=date('Y-m-d ',time()).$nowHore.":".$fmin;
						}
						$minAgo=2;
					}else{
						if(substr_count($changeStr,'今天')>0){
							$changeStr=date('Y-m-d',time()).str_replace("今天",'',$changeStr);
						}else{
							$changeStr=date('Y-',time()).str_replace("日",' ',str_replace(" ",'',str_replace("月",'-',$changeStr)));
						};
					}
					//该博客链接 正则
					preg_match('/(?','',str_replace('"','',strip_tags($changeStr))));
					if($key==2){
						$sqlValue[$k][$key]=date('Y-m-d H:i',strtotime($sqlValue[$k][$key]));
					}
				}
			}
		}
		return $sqlValue;
	}
}

                   

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。