1:创建cnofig.php文件
<?php
//error_reporting(E_ERROR | E_WARNING | E_PARSE);
error_reporting(0);
header("Content-type: text/html; charset=utf-8");
//数据库参数
$dbhost = '192.168.1.235';
//数据库主机名
$dbuser = 'root';
//数据库用户名
$dbpass = '';
//用户名密码
$dbname = 'search_user';
//数据库名
//设置常用的目录常量
define('ROOT_PATH', str_replace('config/config.php', '', str_replace('\\', '/', __FILE__)));
//定义根目录路径
define('INCLUDES_PATH', ROOT_PATH . 'include/');
//定义包含文件目录路径
define( "WB_AKEY" , '1178018680' );
define( "WB_SKEY" , '7c138a273abdbd1e9dbfefe1 4d863ede' );
set_time_limit(0);
//创建mysql对象
require_once(INCLUDES_PATH . 'mysql_class.php');
require_once(INCLUDES_PATH . 'function.php');
require_once(INCLUDES_PATH . 'Snoopy.class.php');
require_once(INCLUDES_PATH . 'weibooauth.php');
$db = new cls_mysql($dbhost, $dbuser, $dbpass, $dbname);
$fun = new functions();
?>
2:模拟登陆
require_once("D:\wamp\www\sina_login\config\config.php");
//抓取数据
$result = get_crwal_result($page_n,$next_page); //$result 就是所抓取回来的数据
function get_crwal_result($page_n,$next_page)
{
$snoopy = new Snoopy();
$result = '';
$out = array();
$user_ids = array();
$snoopy->agent = "Mozilla/5.0 (Windows NT 6.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2";
$snoopy->referer = "http://weibo.com/";
$snoopy->rawheaders["COOKIE"]= 'UOR=account.weibo.com,weibo.com,; ULV=1320108124072:43:1:2:1912939997414.2903.1320108121555:1320031505407; un=haohailuo@163.com; __utma=182865017.1517530439.1316425848.1316425848.1316425848.1; __utmz=182865017.1316425848.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); ads_ck=0; SinaRot//=69; NSC_wjq_xfjcp.dpn_w3.6_w4=ffffffff0941135d45525d5f
4f58455e445a4a423660; NSC_wjq_xfjcp.dpn_ipnfqbhf=ffffffff0941139e45525d5f
4f58455e445a4a423660; _s_tentry=login.sina.com.cn; Apache=1912939997414.2903.1320108121555; SINAGLOBAL=1912939997414.2903.1320108121555; ULOGIN_IMG=13201105005008; WNP=2207464465,255; SUE=es=535657cf266397d4c22c09bd
1afa67d4&ev=v1&es2=b3a4c9f7c839a0b7846429fc
fad0deaa&rs0=dJCTHUF3fquN+vS0jg8NByCb1CAguNin2J4ev
5nn2kpwaWuAjZp0uuCMA3zA3
fdK5LV1nqh/ADMRVMaKbRiXppDSTy/KUZzLlHCshtmWVap0T+WFU6ardC9EdpinfV2Kbk0Iqi
XwfoTySwGYYgkrsDnx1+y7b2dONlpHpbArYWY=&rv=0; SUP=cv=1&bt=1320112600&et=1320199000<=1&uid=1688418300&user=haohailuo@163.com&ag=4&name=haohailuo@163.com&nick=徐浩友&sex=&ps=0&email=&dob=&ln=1688418300&os=&fmp=&lcp=&us=; ALF=1320717399; SSOLoginState=1320112601; wvr=4';
if($next_page)
{
$snoopy->fetch($next_page);
}else
{
$snoopy->fetch("http://s.weibo.com/weibo/亚马逊中国&rd=OTg0N&page=32");
}
//抓取数据
$result = $snoopy->results;
return $result;
}
其中 cookie 是你自己的cookie 大概就是
这个url所对应的cookie信息
snoopy 类请从 官网下载。
<?php
//error_reporting(E_ERROR | E_WARNING | E_PARSE);
error_reporting(0);
header("Content-type: text/html; charset=utf-8");
//数据库参数
$dbhost = '192.168.1.235';
$dbuser = 'root';
$dbpass = '';
$dbname = 'search_user';
//设置常用的目录常量
define('ROOT_PATH', str_replace('config/config.php', '', str_replace('\\', '/', __FILE__)));
define('INCLUDES_PATH', ROOT_PATH . 'include/');
define( "WB_AKEY" , '1178018680' );
define( "WB_SKEY" , '7c138a273abdbd1e9dbfefe1
set_time_limit(0);
//创建mysql对象
require_once(INCLUDES_PATH . 'mysql_class.php');
require_once(INCLUDES_PATH . 'function.php');
require_once(INCLUDES_PATH . 'Snoopy.class.php');
require_once(INCLUDES_PATH . 'weibooauth.php');
$db = new cls_mysql($dbhost, $dbuser, $dbpass, $dbname);
$fun = new functions();
?>
2:模拟登陆
require_once("D:\wamp\www\sina_login\config\config.php");
//抓取数据
$result = get_crwal_result($page_n,$next_page); //$result 就是所抓取回来的数据
function get_crwal_result($page_n,$next_page)
{
}
其中 cookie 是你自己的cookie 大概就是
![snoopy <wbr>模拟新浪微博登陆 snoopy <wbr>模拟新浪微博登陆](https://i-blog.csdnimg.cn/blog_migrate/a4c26d1e5885305701be709a3d33442f.gif)
这个url所对应的cookie信息
snoopy 类请从 官网下载。