Esempio n. 1
0
function getAstroDay($astor_name = '', $day = '')
{
    if (empty($astor_name)) {
        return false;
    }
    if (empty($day)) {
        $day = date('Ymd', strtotime("+1 day"));
    }
    $url = "http://vip.astro.sina.com.cn/astro/view/{$astor_name}/day/{$day}";
    echo $url . "\n";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $content = curl_exec($ch);
    if (curl_errno($ch)) {
        echo curl_error($ch);
    }
    #else echo $content;
    curl_close($ch);
    $tg = "/作者\\/(.*?)<\\/cite>/ims";
    $d = preg_match($tg, $content, $matches);
    $data['author'] = $matches[1];
    $tg = "/<div class=\"lotconts\">(.*?)<\\/div>/ims";
    $d = preg_match($tg, $content, $matches);
    $data['content'] = $matches[1];
    $tg = "/<div class=\"tab\"><h4>综合运势<\\/h4><p>(.*?)<\\/p>/ims";
    $d = preg_match($tg, $content, $matches);
    $num = getImgCount($matches[1]);
    $data['sum'] = $num;
    $tg = "/<div class=\"tab\"><h4>爱情运势<\\/h4><p>(.*?)<\\/p>/ims";
    $d = preg_match($tg, $content, $matches);
    $num = getImgCount($matches[1]);
    $data['love'] = $num;
    $tg = "/<div class=\"tab\"><h4>工作状况<\\/h4><p>(.*?)<\\/p>/ims";
    $d = preg_match($tg, $content, $matches);
    $num = getImgCount($matches[1]);
    $data['work'] = $num;
    $tg = "/<div class=\"tab\"><h4>理财投资<\\/h4><p>(.*?)<\\/p>/ims";
    $d = preg_match($tg, $content, $matches);
    $num = getImgCount($matches[1]);
    $data['money'] = $num;
    $tg = "/<div class=\"tab\"><h4>健康指数<\\/h4><p>(.*?)<\\/p><\\/div>/ims";
    $d = preg_match($tg, $content, $matches);
    $data['health'] = str_replace('%', '', $matches[1]);
    $tg = "/<div class=\"tab\"><h4>商谈指数<\\/h4><p>(.*?)<\\/p><\\/div>/ims";
    $d = preg_match($tg, $content, $matches);
    $data['bussiness'] = str_replace('%', '', $matches[1]);
    $tg = "/<div class=\"tab\"><h4>幸运颜色<\\/h4><p>(.*?)<\\/p><\\/div>/ims";
    $d = preg_match($tg, $content, $matches);
    $data['luck_color'] = $matches[1];
    $tg = "/<div class=\"tab\"><h4>幸运数字<\\/h4><p>(.*?)<\\/p><\\/div>/ims";
    $d = preg_match($tg, $content, $matches);
    $data['luck_num'] = $matches[1];
    $tg = "/<div class=\"tab\"><h4>速配星座<\\/h4><p>(.*?)<\\/p><\\/div>/ims";
    $d = preg_match($tg, $content, $matches);
    $data['luck_astro'] = $matches[1];
    $data['day'] = $day;
    return $data;
}
Esempio n. 2
0
function getAstroMonth($astor_name = '', $day = '')
{
    if (empty($astor_name)) {
        return false;
    }
    if (empty($month)) {
        $month = date('Ym');
    }
    $url = "http://vip.astro.sina.com.cn/astro/view/{$astor_name}/monthly/";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $content = curl_exec($ch);
    if (curl_errno($ch)) {
        echo curl_error($ch);
    }
    #else echo $content;
    curl_close($ch);
    $tg = "/作者\\/(.*?)<\\/cite>/ims";
    $d = preg_match($tg, $content, $matches);
    $data['author'] = $matches[1];
    $tg = "/<div class=\"lotconts\">(.*?)<\\/div>/ims";
    $d = preg_match($tg, $content, $matches);
    $data['content'] = $matches[1];
    $tg = "/<h4>整体运势(.*?)<\\/h4>(.*?)<p>(.*?)<\\/p>/is";
    $d = preg_match($tg, $content, $matches);
    $num = getImgCount($matches[1]);
    $data['sum'] = $num;
    $data['sum_content'] = $matches[3];
    $tg = "/<h4>爱情运势(.*?)<\\/h4>(.*?)<p>(.*?)<\\/p>/is";
    $d = preg_match($tg, $content, $matches);
    $num = getImgCount($matches[1]);
    $data['love'] = $num;
    $data['love_content'] = $matches[3];
    $tg = "/<h4>投资理财运(.*?)<\\/h4>(.*?)<p>(.*?)<\\/p>/is";
    $d = preg_match($tg, $content, $matches);
    $num = getImgCount($matches[1]);
    $data['money'] = $num;
    $data['money_content'] = $matches[3];
    $tg = "/<h4>解压方式(.*?)<\\/h4>(.*?)<p>(.*?)<\\/p>/is";
    $d = preg_match($tg, $content, $matches);
    $data['relax_way'] = $matches[3];
    $tg = "/<h4>开运小秘诀(.*?)<\\/h4>(.*?)<p>(.*?)<\\/p>/is";
    $d = preg_match($tg, $content, $matches);
    $data['luck_way'] = $matches[3];
    $data['month'] = $month;
    return $data;
}
Esempio n. 3
0
function getAstroWeek($astor_name = '', $day = '')
{
    if (empty($astor_name)) {
        return false;
    }
    if (empty($day)) {
        $day = date('Ymd');
    }
    $url = "http://vip.astro.sina.com.cn/astro/view/{$astor_name}/weekly";
    echo $url . "\n";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $content = curl_exec($ch);
    if (curl_errno($ch)) {
        echo curl_error($ch);
    }
    #else echo $content;
    curl_close($ch);
    $tg = "/作者\\/(.*?)<\\/cite>/ims";
    $d = preg_match($tg, $content, $matches);
    $data['author'] = $matches[1];
    $tg = "/<li class=\"notes\">(.*?)<\\/li>/ims";
    $d = preg_match($tg, $content, $matches);
    $data['content'] = $matches[1];
    $tg = "/<h4>整体运势(.*?)<\\/h4>(.*?)<p>(.*?)<\\/p>/is";
    $d = preg_match($tg, $content, $matches);
    $num = getImgCount($matches[1]);
    $data['sum'] = $num;
    $data['sum_content'] = $matches[3];
    $tg = "/<h4>爱情运势(.*?)<\\/h4>(.*?)<p>(.*?)<\\/p>/is";
    //有对象 无对象
    $tg = "/<h4>爱情运势<\\/h4>(.*?)<em>有对象:(.*?)<\\/em>(.*?)<em>没对象:(.*?)<\\/em>(.*?)<\\/div>/is";
    $d = preg_match($tg, $content, $matches);
    $num = getImgCount($matches[2]);
    $data['love'] = $num;
    $data['love_content'] = $matches[3];
    $num = getImgCount($matches[4]);
    $data['love_no'] = $num;
    $data['love_content_no'] = $matches[5];
    $tg = "/<h4>健康运势(.*?)<\\/h4>(.*?)<p>(.*?)<\\/p>/is";
    $d = preg_match($tg, $content, $matches);
    $num = getImgCount($matches[1]);
    $data['study'] = $num;
    $data['study_content'] = $matches[3];
    $tg = "/<h4>工作学业运(.*?)<\\/h4>(.*?)<p>(.*?)<\\/p>/is";
    $d = preg_match($tg, $content, $matches);
    $num = getImgCount($matches[1]);
    $data['work'] = $num;
    $data['work_content'] = $matches[3];
    $tg = "/<h4>性欲指数(.*?)<\\/h4>(.*?)<p>(.*?)<\\/p>/is";
    $d = preg_match($tg, $content, $matches);
    $num = getImgCount($matches[1]);
    $data['sex'] = $num;
    $data['sex_content'] = $matches[3];
    $tg = "/<h4>红心日<\\/h4>(.*?)<p>(.*?)<br \\/>(.*?)<\\/p>/is";
    $d = preg_match($tg, $content, $matches);
    $data['red'] = $matches[2];
    $data['red_content'] = $matches[3];
    $tg = "/<h4>黑梅日<\\/h4>(.*?)<p>(.*?)<br \\/>(.*?)<\\/p>/is";
    $d = preg_match($tg, $content, $matches);
    $data['black'] = $matches[2];
    $data['black_content'] = $matches[3];
    $date = date('Y-m-d');
    $ret = getWeekRange($date);
    $data['day'] = date('Ymd');
    $data['day_start'] = $ret['day_start'];
    $data['day_end'] = $ret['day_end'];
    //星期开始日
    //星期结束日
    return $data;
}