php使用curl抓取qq空间的访客信息示例(5)

parent::__construct(dirname($cookie_file) . 'https://www.jb51.net/' . $user . '.' . basename($cookie_file), $request_timeout, $debug, $end_line);
        $this->user = $user;
        $this->password = $password;
    }
}


class ResultExtract
{

public static function  getCoreJsInfo($content, $user)
    {
        $arr = array();
        preg_match('/cfg\s*=\s*\{(.*?)\s*\}\s*,\s*URL_PARAM_HASH/s', $content, $m);
        if (count($m) > 0) {
            $f = preg_replace('/\s*/', '', $m[1]);
            $f = preg_replace('/"\+g\_iLoginUin\+"/', $user, $f);
            $f = preg_replace('/\$j\.cookie.get\("hotfeeds_closed"\)==1\?""\:/', '', $f);

$f = explode(",", $f);
            if (count($f) > 0) {
                foreach ($f as $t) {
                    $t = trim($t);
                    $p = strpos($t, ':');
                    $key = trim(substr($t, 0, $p), '"');
                    $value = trim(substr($t, $p + 1), '"');
                    if ($key) {
                        $arr[$key] = $value;
                    }
                }

if (count($arr) > 0) {
                    $arr['visitor'] = $arr;
                }
            }
        }

return $arr;
    }

public static function  enterQzoneSuccess($content)
    {
        $arr = array();
        $arr2 = array();
        preg_match('/g_Data\s*=\s*{\s*feedsPart1\s*:\s*(.*?)\s*,\s*feedsPart2/s', $content, $m);

if (count($m) > 0) {
            $f = preg_replace('/\s*/', '', $m[1]);
            $f = preg_replace('/([\{,])([^,]*?)(\:)/', '$1"$2"$3', $f);
            $f = preg_replace('/:\'(.*?)\'([,\}])/', ':"$1"$2', $f);
            $arr = json_decode($f, true);
            $arr = $arr['main'];
        }

preg_match('/g_type.*?g_IZone_Flag/s', $content, $m);

if (count($m) > 0) {
            $f = preg_replace('/\s*/', '', $m[0]);
            $f = explode(",", $f);

foreach ($f as $t) {
                $t = trim($t);
                $p = strpos($t, '=');
                $key = trim(substr($t, 0, $p));
                $value = trim(substr($t, $p + 1), '"');
                if ($key) {
                    $arr2[$key] = $value;
                }
            }
        }

return array_merge($arr, $arr2);

}

public static function getLoginJsInfo($content)
    {

$s = preg_replace('/.*?pt\.plogin\s*=\s*\{(.*?)aqScanLink.*/s', '$1', $content);
        preg_match('/.*js_type\s*:\s*(\d+)\s*,.*/', $s, $m);

if (count($m) > 1) {
            return array('js_type' => $m[1]);
        }

return array();
    }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/6a3b396fe61b016e0da9eb2453f6669b.html