前段时间出于好玩,便写了一个获取腾讯星座信息的小偷函数,初学,希望大家多指教
后来封装成类了,但是不好意思,那些文件由于网络硬盘的问题,找不到了
改天重新补上
函数代码如下:
function getastros($astros,$thetime)
{
$url = "http://appastro.qq.com/cgi...
$handle = fopen($url,"r");
while(!feof($handle))
{
$str.=fread($handle,1024);
}
fclose($handle);
preg_match_all("/:(.+?)<//td>/", $str, $out);
for($i=0;$i<=count($out[0]);$i++)
{
$str_out.= $out[0][$i];
}
$str_out = trim(str_replace(":","",$str_out));
$str_out = trim(str_replace("</td>","|",$str_out));
$str_out = trim(str_replace("</b><br>","",$str_out));
$str_out = trim(str_replace(" ","",$str_out));
$str_out = trim(str_replace(" ","",$str_out));
$str_out = trim(str_replace("/r","",$str_out));
$str_out = trim(str_replace("%","",$str_out));
$str_out = substr($str_out,0,-1);
$array_strinfunction = explode("|",$str_out);
return $array_strinfunction;
}
后来封装成类了,但是不好意思,那些文件由于网络硬盘的问题,找不到了
改天重新补上
函数代码如下:
function getastros($astros,$thetime)
{
$url = "http://appastro.qq.com/cgi...
$handle = fopen($url,"r");
while(!feof($handle))
{
$str.=fread($handle,1024);
}
fclose($handle);
preg_match_all("/:(.+?)<//td>/", $str, $out);
for($i=0;$i<=count($out[0]);$i++)
{
$str_out.= $out[0][$i];
}
$str_out = trim(str_replace(":","",$str_out));
$str_out = trim(str_replace("</td>","|",$str_out));
$str_out = trim(str_replace("</b><br>","",$str_out));
$str_out = trim(str_replace(" ","",$str_out));
$str_out = trim(str_replace(" ","",$str_out));
$str_out = trim(str_replace("/r","",$str_out));
$str_out = trim(str_replace("%","",$str_out));
$str_out = substr($str_out,0,-1);
$array_strinfunction = explode("|",$str_out);
return $array_strinfunction;
}