Abbey 发表于 2019-1-21 13:52:49

听说你们的loc签到脚本不好使了?

本帖最后由 Abbey 于 2019-1-21 13:59 编辑


0074MymAgy1fze5g41e04j314k0nvdml.jpg


[*]#-*- coding=utf-8 -*-
[*]import requests
[*]import re
[*]import sys
[*]import urllib3
[*]import time
[*]
[*]urllib3.disable_warnings()
[*]
[*]index='https://www.hostloc.com/'
[*]page_url='https://www.hostloc.com/forum-45-1.html'
[*]credit_url='https://www.hostloc.com/home.php?mod=spacecp&ac=credit&showcredit=1'
[*]login_url='https://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'
[*]    }
[*]headers={
[*]    'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
[*]    ,'Accept-Encoding':'gzip, deflate, sdch'
[*]    ,'Accept-Language':'zh-CN,zh;q=0.8,en;q=0.6'
[*]    ,'Host':'www.hostloc.com'
[*]    ,'Referer':'https://www.hostloc.com/forum.php'
[*]    ,'Upgrade-Insecure-Requests':'1'
[*]    ,'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'
[*]}
[*]
[*]
[*]class HostLoc():
[*]    def __init__(self,username,passwd):
[*]      self.username=username
[*]      self.passwd=passwd
[*]      self.session=requests.Session()
[*]      self.session.headers=headers
[*]      login_data['username']=username
[*]      login_data['password']=passwd
[*]      login_data['formhash']=self.get_hidden_value(index,'formhash')
[*]      self.login()
[*]
[*]
[*]    def login(self):
[*]      self.session.post(login_url,data=login_data,verify=False)
[*]
[*]    def isLogin(self):
[*]      url='https://www.hostloc.com/home.php?mod=spacecp'
[*]      html=self.session.get(url).text
[*]      UserName=re.findall(self.username,html)
[*]      if len(UserName)==0:
[*]            return False
[*]      else:
[*]            return True
[*]
[*]    def get_credit(self):
[*]      html=self.session.get(credit_url,verify=False).text
[*]      credit_pattern=re.compile(u' 金钱: (.*?).*? [\w\W]*?[*] 威望: (.*?) [\w\W]*?积分: (.*?) ')
[*]      try:
[*]            credit=credit_pattern.findall(html)
[*]            coin,wh,jf=credit
[*]            print(u"{} coin:{},wei wang:{},jifen:{}".format(self.username,coin,wh,jf))
[*]            return True
[*]      except Exception as e:
[*]            print(u"{} fetch data error!:{}".format(self.username,e))
[*]            return False
[*]
[*]    def get_user(self):
[*]      print('parse '+page_url)
[*]      self.html=self.session.get(page_url,verify=False).text
[*]      user_pattern=re.compile('space-uid-\d+?.html')
[*]      users=list(set(user_pattern.findall(self.html)))
[*]      self.users=
[*]
[*]    def visit_user(self):
[*]      for user in self.users[:10]:
[*]            print('visit user '+user)
[*]            self.session.get(user)
[*]
[*]    def get_hidden_value(self,url,keyname):
[*]      r=self.session.get(url)
[*]      cont=r.text
[*]      value=re.findall(''.format(keyname),cont)
[*]      return value
[*]
[*]
[*]def start():
[*]    #多用户配置
[*]    #格式为:[,,]
[*]    users=[
[*]      ['user1','password1'],
[*]      ['user2','password2'],
[*]    ]
[*]    for username,passwd in users:
[*]      hostloc=HostLoc(username,passwd)
[*]      if hostloc.get_credit():
[*]            hostloc.get_user()
[*]            hostloc.visit_user()
[*]            hostloc.get_credit()
[*]
[*]
[*]def main_handler(event, context):
[*]    return start()
[*]
[*]if __name__=='__main__':
[*]    start()复制代码

发上我的脚本,搭配
腾讯云scf(无服务器函数)每天自动签到
,scf配置内容:

0074MymAly1fze5jiajsrj30ij0fgq3l.jpg


设置好用户名和密码,支持多用户签到

xiaobei206 发表于 2019-1-22 01:10:06

我自己python写的无压力

学到了么 发表于 2019-1-21 18:33:16

是CC防护的原因,现在登陆正常了

memorylv 发表于 2019-1-21 18:28:52

你这个没有提交js 那个字符串,肯定不行

今晚我是你的 发表于 2019-1-21 14:13:11

牛逼

一库一库 发表于 2019-1-21 13:55:39

mark,感谢分享

wolfewong 发表于 2019-1-21 13:57:08

我的监控已经修复。又可以抢沙发了。

hxuf 发表于 2019-1-21 13:57:37

业界良心

EvilPoet 发表于 2019-1-21 13:57:52

本帖最后由 leassy 于 2019-1-21 14:04 编辑

刚试了一下你的代码也不行啊
HTTP 错误 502.2 - Bad Gateway
指定的 CGI 应用程序由于未返回完整的一组 HTTP 头而产生错误行为。它实际返回的头是“

leassy 发表于 2019-1-21 14:03:26

大佬牛逼
页: [1] 2 3 4
查看完整版本: 听说你们的loc签到脚本不好使了?