forked from za2016/pythoncode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6684e05
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# hostloc赚金币脚本 | ||
|
||
打开脚本修改**username**和**passwd**为自己的用户名和密码 | ||
|
||
然后直接运行**python hostloc.py**即可 | ||
|
||
每天运行一次,每次获取20金币,升元老指日可待2333 | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#-*- coding=utf-8 -*- | ||
import requests | ||
import re | ||
import cookielib | ||
|
||
index='http://www.hostloc.com/' | ||
page_url='http://www.hostloc.com/forum-45-1.html' | ||
login_url='http://www.hostloc.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1' | ||
login_data={ | ||
'fastloginfield':'username' | ||
,'username':'' | ||
,'cookietime':'2592000' | ||
,'password':'' | ||
,'quickforward':'yes' | ||
,'handlekey':'ls' | ||
} | ||
|
||
class HostLoc(): | ||
def __init__(self,username,passwd): | ||
self.username=username | ||
self.passwd=passwd | ||
login_data['username']=username | ||
login_data['password']=passwd | ||
self.session=requests.Session() | ||
self.session.cookies = cookielib.LWPCookieJar(filename='cookies') | ||
try: | ||
self.session.cookies.load(ignore_discard=True) | ||
if self.isLogin(): | ||
self.login() | ||
except: | ||
self.login() | ||
|
||
def login(self): | ||
self.session.post(login_url,data=login_data) | ||
self.session.cookies.save() | ||
|
||
def isLogin(self): | ||
url='http://www.hostloc.com/home.php?mod=spacecp' | ||
html=self.session.get(url).content | ||
UserName=re.findall(self.username,html) | ||
if len(UserName)==0: | ||
return False | ||
else: | ||
return True | ||
|
||
def get_user(self): | ||
print('parse '+page_url) | ||
self.html=self.session.get(page_url).text | ||
user_pattern=re.compile('space-uid-\d+?.html') | ||
users=list(set(user_pattern.findall(self.html))) | ||
self.users=[index+i for i in users] | ||
|
||
def visit_user(self): | ||
for user in self.users[:10]: | ||
print('visit user '+user) | ||
self.session.get(user) | ||
|
||
|
||
if __name__=='__main__': | ||
username='' #用户名 | ||
passwd='' #密码 | ||
hostloc=HostLoc(username,passwd) | ||
hostloc.get_user() | ||
hostloc.visit_user() |