问答详情
源自:2-4 用cURL登陆慕课网并下载个人空间页面

如何使用CURL采集CNZZ数据

$cookie_file = tempnam('./wei1','wei');

$login_url  = 'http://web.umeng.com/main.php?c=user&a=login';

$post_fields ='username=88888&password=123456';

$ch = curl_init($login_url);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);

curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);

$arr=curl_exec($ch);

curl_close($ch);



$url='https://web.umeng.com/main.php?siteid=1256657021&c=flow&a=trend&ajax=module=flash&st=2016-08-09&et=2016-08-09&type=Line&Period=Hour&Quota=pv&_=1470735753213';

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);

$contents = curl_exec($ch);

echo $contents;

curl_close($ch);

这样写有什么不对吗,都登录不上CNZZ, 是怎么回事?

提问者:China_好备胎 2016-08-09 17:51

个回答

  • qq_放肆青春_03307463
    2017-01-11 13:31:41

    cnzz的用户名和密码字段名应该不是username和password,去百度一下就知道字段名是什么了