HostLoc论坛自动签到脚本

PHP版签到

版本一

新建loc.php

<?php
$lines = file(dirname(__FILE__).'/list.txt');
foreach($lines as $line){
        list($username, $password) = explode('#', $line);
        $username = trim($username);
        $password = trim($password);
        if(empty($username) || empty($password)){
                continue;
        }

        $suburl = "https://www.hostloc.com/member.php?mod=logging&action=login";
        $loginInfo = array(
                  "fastloginfield" => "username",
                "username" => $username,
                "password" => $password,
                "quickforward" => "yes",
                "handlekey" => "ls",
                "loginsubmit" => true
        );

        echo "login($username) ... ";
        $login = curl_post($suburl,$loginInfo);
        
        if(strpos($login, $username) !== FALSE){
 
                preg_match("/>用户组: (.*?)<\/a>/", $login, $preg);
                $group = $preg[1];
                echo "Success!($group)\n";
        }else{
                echo "Failed!\n\n";
                continue;
        }
        extract(get_jf());
        echo "Credit: $credit; Money: $money\n";
 
        echo "Visting user space ";
        for($i=0;$i<20;$i++){
                $uid = mt_rand(10000,20000);
                curl_get('https://www.hostloc.com/space-uid-'.$uid.'.html');
                  sleep(1);
                echo ".";
        }
        echo " done!\n";
        extract(get_jf());
        echo "Credit: $credit; Money: $money\n\n";
}

function get_jf(){
        $data = array();
        $html = curl_get("https://www.hostloc.com/home.php?mod=spacecp&ac=credit&op=base");
        preg_match("/积分: (\d+)<\/a>/", $html, $preg);
        if(!empty($preg[1])){
                $data['credit'] = $preg[1];
        }else{
                $data['credit'] = 0;
        }
        preg_match("/金钱: <\/em>(\d+)/", $html, $preg);
        if(!empty($preg[1])){
                $data['money'] = $preg[1];
        }else{
                $data['money'] = 0;
        }

        return $data;
}
 
function curl_post($url, $post_data){
    $ch = curl_init ();
    curl_setopt($ch, CURLOPT_POST , 1);
    curl_setopt($ch, CURLOPT_HEADER , 0);
    curl_setopt($ch, CURLOPT_URL , $url);
    curl_setopt($ch, CURLOPT_COOKIEJAR , '/tmp/hostloc.cookie');
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:'.rand_ip())); 
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible;Baiduspider-render/2.0; +http://www.baidu.com/search/spider.html)');
    curl_setopt($ch, CURLOPT_POSTFIELDS , $post_data);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    //curl_setopt($ch, CURLOPT_TIMEOUT,6000);
    curl_setopt($ch, CURLOPT_REFERER, 'https://www.hostloc.com/');
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}
 
function curl_get($url){
    $ch = curl_init ();
    curl_setopt($ch, CURLOPT_HEADER , 0);
    curl_setopt($ch, CURLOPT_URL , $url);
    curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/hostloc.cookie');
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:'.rand_ip())); 
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible;Baiduspider-render/2.0; +http://www.baidu.com/search/spider.html)');
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT,6000);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}

function rand_ip(){
    return rand(1,255).'.'.rand(1,255).'.'.rand(1,255).'.'.rand(1,255);
}

新建list.txt

格式为:

账号#密码
账号#密码....

版本二

<?php
$useList = array(
                                '账号1'=>'密码1',
                                '账号2'=>'密码2',
                                '账号3'=>'密码3',
                                );
header("Content-Type: text/html; charset=utf-8");
foreach($useList as $k=>$v){
        locSign($k,$v);
}
function locSign($use,$pwd){
        $html = http_post('https://www.hostloc.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1','fastloginfield=username&username='.urlencode($use).'&cookietime=2592000&password='.urlencode($pwd).'&quickforward=yes&handlekey=ls');
        if(!strrpos($html,'window.location.href')){echo $use.' login error<br>';return false;}
        $cookie = getCookie($html,'Set-Cookie: ',';');
        for($i=26200; $i<=26210; $i++){
                $html = http_get("https://www.hostloc.com/space-uid-{$i}.html",$cookie);
        }
        echo $use.' Sign ok!!!<br>';
}
function http_get($url,$cookie) {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_HTTPHEADER,array('User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0','Referer: https://www.hostloc.com/forum-45-1.html','Cookie: '.$cookie));
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        $src = curl_exec($ch);
        curl_close($ch);
        return $src;
}
function http_post($url,$body){
        $ch = curl_init();  
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);  
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);  
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($ch, CURLOPT_HTTPHEADER,array('User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0','Referer: https://www.hostloc.com/forum.php'));
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $body);        
        $result = curl_exec($ch);  
        curl_close($ch);  
        return $result;    
}
function getCookie($str,$leftStr,$rightStr){
        if(strrpos($str,$leftStr) == false || strrpos($str,$rightStr) == false){return '';}
        $arr1 = explode($leftStr,$str);$i = 0;$cookie = '';
        foreach($arr1 as $k=>$v){$i++;if($i > 1){$arr2 = explode($rightStr,$v);$cookie .= $arr2[0].'; ';}}
        return $cookie;
}

python版本

安装 Python3

apt-get install python3-pip

 

新建PY文件

名字随便起,不要在自己的电脑用文本编辑,使用宝塔新建,站长这里是建在/home/www里的,名字就是loc.py,然后把以下脚本复制进去,账号和密码那里改成自己的,可以多个账号使用。

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import re
import sys
import time
from urllib import request, parse
from http import cookiejar


account_dict = {
    '0': {'username': '账号A', 'password': '密码A'},
    '1': {'username': '账户B', 'password': '密码B'},
}


def Login(URL, UserData):
    _cookies = ''
    _cookie = cookiejar.CookieJar()
    _handler = request.HTTPCookieProcessor(_cookie)
    _req = request.Request(URL, data=parse.urlencode(UserData).encode('utf-8'))
    request.build_opener(_handler).open(_req)
    for cookie in _cookie:
        _cookies += cookie.name + '=' + cookie.value + ';'
    return _cookies


def GetPage(URL, Header_Cookies):
    _Header = {'Cookie': str(Header_Cookies)}
    _req = request.Request(URL, headers=_Header)
    return request.urlopen(_req).read().decode('utf-8')


def GetCredit(user_data, proto='https'):
    username = user_data['username']
    Login_URL = proto + '://hostloc.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1'
    My_Credit = proto + '://hostloc.com/home.php?mod=spacecp&ac=credit&showcredit=1&inajax=1'
    My_Home = proto + '://hostloc.com/home.php?mod=spacecp&inajax=1'
    My_Cookies = Login(Login_URL, user_data)

    if '<td>' + str(username) + '</td>' not in GetPage(My_Home, My_Cookies):
        print('[%s] Login Fail!' % username)
    else:
        try:
            CreditNum0 = str(re.findall('[0-9]+', GetPage(My_Credit, My_Cookies))[-1])
        except:
            CreditNum0 = 'Null'
        for x in range(25297, 25309):
            GetPage(proto + '://hostloc.com/space-uid-{}.html'.format(x), My_Cookies)
            time.sleep(4)
        try:
            if CreditNum0 == 'Null':
                raise Exception
            CreditNum1 = str(re.findall('[0-9]+', GetPage(My_Credit, My_Cookies))[-1])
            if CreditNum0 == CreditNum1:
                CreditDetails = str(CreditNum1)
            else:
                CreditDetails = str(CreditNum0) + '->' + str(CreditNum1)
        except:
            CreditDetails = 'Null'
        print('[%s] Login Success! (Credit: %s)' % (username, CreditDetails))


if __name__ == '__main__':
    if len(sys.argv) > 1:
        n = 0
        account_dict = {}
        account_list = [sys.argv[x] for x in range(1, len(sys.argv))]
        for account in account_list:
            if ":" not in account:
                continue
            account_dict[str(n)] = {}
            account_dict[str(n)]['username'] = str(str(account).split(":", 1)[0])
            account_dict[str(n)]['password'] = str(str(account).split(":", 1)[-1])
            n += 1
    for i in range(0, len(account_dict)):
        try:
            GetCredit(account_dict[str(i)])
            time.sleep(4)
        except:
            continue

计划任务

在宝塔的计划任务添加个Shell脚本,按以下输入就可以每天定时领取20金币,账号放在那里150天就可以升级元老了,不过你要多去灌水会升级更快,另外版主们也会不定时清理刷分号。

创建自动执行签到任务
在宝塔面板创建一个 Shell 脚本自动计划任务

cd /home/www
python3 ./loc.py

创建完成后点击执行,等待执行完成后查看日志,如果没有问题就可以了!

提示: 尽量将自动签到时间设定到半夜,白天论坛的 CC 防御规则严格,会使签到失败,设置在半夜就没问题了。

 

© 版权声明
THE END
如果喜欢,可以【点赞】【分享】【收藏】
点赞7赞赏 分享
评论 抢沙发
头像
非注册用户需审核通过后才能查看。友好交流,勿发纯表情,勿恶意灌水!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容