首页 > 开发 > PHP > 正文

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

2024-05-04 22:22:15
字体:
来源:转载
供稿:网友

config.php

代码如下:
<?php
define('APP_DIR', dirname(__FILE__));
define('COOKIE_FILE', APP_DIR . '/app.cookie.txt'); //会话记录文件
define('VISITOR_CAPTURE_INTERVAL', 3); //QQ采集间隔
define('VISITOR_DATA_UPLOAD_INTERVAL', '');
define('THIS_TIME', time());

define('REQUEST_TIMEOUT', 20); //请求超时20秒
define('END_LINE', "/n");
define('DEBUG', true); //开启调试

$login_users = array(
    array('user' => '2064556526', 'password' => '909124951'),
    array('user' => '483258700', 'password' => '909124951'),
    array('user' => '1990270522', 'password' => '909124951'),
    array('user' => '2718711637', 'password' => '909124951'),
    array('user' => '2841076562', 'password' => '909124951'),
);

qy.visitor.php

代码如下:
<?php
include('./config.php');
include(APP_DIR . '/qy.visitor.php');

$sessions = array();
$user = $login_users[array_rand($login_users)];

$visitor_capture = new QQVisitorCapture($user['user'], $user['password'], COOKIE_FILE, REQUEST_TIMEOUT, DEBUG, END_LINE);

$visitors = $visitor_capture->getVisitorInfo();

if (empty($visitors)) {
    $this->clearCookies(true);
} else {
    $cckf_service = new CCKFService(SECURITY_KEY,SERVICE_ID,SERVICE_ADDRESS,'', REQUEST_TIMEOUT, DEBUG, END_LINE);
}

qy.class.php

代码如下:
<?php


class Trace
{
    public static function nl($num = 1)
    {
        $str = '';
        for ($i = 0; $i < $num; $i++) {
            $str .= "/n";
        }
        return $str;
    }

    public static function br($num = 1)
    {
        $str = '';
        for ($i = 0; $i < $num; $i++) {
            $str .= "<br/>";
        }
        return $str;
    }

    public static function write($content, $end_line, $title = null)
    {
        $close = '^^^^^^^^^^^^^^^^^';

        if ($title) {
            $start = '--------' . $title . '---------';
        } else {
            $start = '-----------------';
        }

        echo $start . $end_line;

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表