Skip to content

Commit

Permalink
hostloc获取金币
Browse files Browse the repository at this point in the history
  • Loading branch information
za2016 committed Dec 22, 2016
0 parents commit 6684e05
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
9 changes: 9 additions & 0 deletions hostloc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# hostloc赚金币脚本

打开脚本修改**username****passwd**为自己的用户名和密码

然后直接运行**python hostloc.py**即可

每天运行一次,每次获取20金币,升元老指日可待2333


64 changes: 64 additions & 0 deletions hostloc/hostloc.py
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()

0 comments on commit 6684e05

Please sign in to comment.