虾米自动签到
<?php | |
set_time_limit(0); | |
/*输入账号密码*/ | |
$name = ''; | |
$password = ''; | |
//获取登陆cookie | |
$curl_post = 'email='.$name.'&password='.$password.'&done=/&submit=登 录'; | |
$cookie_file = dirname(__FILE__).'/cookie.txt'; | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_URL, "http://www.xiami.com/member/login"); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($curl, CURLOPT_POST, 1); | |
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post); | |
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_file); | |
$result = curl_exec($curl); | |
curl_close($curl); | |
//获取手机版首页 | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_URL, "http://www.xiami.com/web"); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie_file); | |
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_file); | |
$data = curl_exec($curl); | |
curl_close($curl); | |
//获取签到URL,如果已经签到则获取签到天数 | |
$preg = '/\<a class\=\"check\_in\" href\=\"(.*?)\"\>每日签到\<\/a\>/s'; | |
preg_match_all($preg, $data, $match); | |
if(!isset($match[1][0])) { | |
$preg = '/\<div class\=\"idh\"\>(已连续签到.*?天)\<\/div\>/s'; | |
preg_match_all($preg, $data, $match); | |
die($match[1][0]); | |
} | |
//定义签到页面 | |
$url = 'http://www.xiami.com' . $match[1][0]; | |
//以上代码验证没有问题 | |
//自动签到 | |
$headers = array("Host: www.xiami.com", "Referer: http://www.xiami.com"); | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_URL, $url); | |
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie_file); | |
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); | |
curl_exec($curl); | |
echo '<pre>'; | |
print_r(curl_getinfo($curl, CURLINFO_HEADER_OUT)); | |
echo '</pre>'; | |
curl_close($curl); | |
?> | |
This comment has been minimized.
This comment has been minimized.
明显是测试账号嘛 |
This comment has been minimized.
This comment has been minimized.
@Cufr 你都搜到Github上来了肿么会不知道肿么用-_-! |
This comment has been minimized.
This comment has been minimized.
@linkarys 是的,测试账号,不过没删掉也是有点小尴尬的,=——=! |
This comment has been minimized.
This comment has been minimized.
这个代码一用就用到2015年,特地跑来感谢下…… |
This comment has been minimized.
This comment has been minimized.
Good one! Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
这位大哥,这东西真有啊,求教下肿么用呢,还有…你密码暴露了 = =