-
-
Save powersee/76f1b9ef584507813256973f877b1d3d to your computer and use it in GitHub Desktop.
看到有需要502论坛自动签到脚本,支持多马甲
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: UTF-8 -*- | |
#forked from https://www.hostloc.com/forum.php?mod=viewthread&tid=452950 | |
import sys | |
from urllib import request | |
from http import cookiejar | |
from random import randint | |
account_dict = { | |
'0': {'username': 'xxxx', 'password': 'xxx'}, | |
'1': {'username': 'yyyy', 'password': 'xxx'}, | |
'2': {'username': 'zzzz', 'password': 'xxx'}, | |
} | |
def Login(URL, UserData): | |
__cookies = '' | |
__cookie = cookiejar.CookieJar() | |
__handler = request.HTTPCookieProcessor(__cookie) | |
__req = request.Request(URL, data=str(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) | |
#sys.stdout.buffer.write(request.urlopen(__req).read()) | |
sys.stdout.buffer.write(b"Accessed "+URL.encode()+b'\n') | |
return request.urlopen(__req).read().decode('utf-8') | |
def GetCredit(username, password): | |
Login_URL = 'https://www.hostloc.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1' | |
My_Home = 'https://www.hostloc.com/home.php?mod=spacecp&inajax=1' | |
user_data = 'username=' + str(username) + '&' + 'password=' + str(password) | |
My_Cookies = Login(Login_URL, user_data) | |
if '<td>' + str(username) + '</td>' not in GetPage(My_Home, My_Cookies): | |
isLogin = False | |
print('[%s] Login Fail!' % username) | |
else: | |
isLogin = True | |
print('[%s] Login Success!' % username) | |
if isLogin: | |
for __x in range(1, 15): | |
__x = randint(2597, 31309) | |
__url = 'https://www.hostloc.com/space-uid-{}.html'.format(__x) | |
GetPage(__url, My_Cookies) | |
if __name__ == '__main__': | |
for __i in range(0, len(account_dict)): | |
GetCredit(account_dict[str(__i)]['username'], account_dict[str(__i)]['password']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment