|
发表于 2019-1-21 00:50:24
|
显示全部楼层
[ol]# -*- coding: utf8 -*-import requestsimport refrom urllib.parse import quotefrom datetime import *bjtime=str(datetime.utcnow().replace(tzinfo=timezone.utc).astimezone(timezone(timedelta(hours=8)))).split('.')[0]def start(): s = requests.session() username = '账号账号账号账号' password = '密码密码密码密码' headers={ 'Host': 'www.hostloc.com', 'Connection': 'keep-alive', 'Cache-Control': 'max-age=0', 'Origin': 'https://www.hostloc.com', 'Upgrade-Insecure-Requests': '1', 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', 'Referer': 'https://www.hostloc.com/forum.php', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-HK,zh;q=0.9,zh-CN;q=0.8,en-US;q=0.7,en;q=0.6,zh-TW;q=0.5' } login_url = 'https://www.hostloc.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1' s.post(login_url, {'fastloginfield':'username','quickforward':'yes','handlekey':'1s',"username": username, 'password': password}, headers=headers) user_info = s.get('https://www.hostloc.com/home.php?mod=spacecp&ac=credit', headers=headers).text current_money = re.search(r'积分: (\d+).+?', user_info).group(1) print("用户%s,签到前你的积分为%s" % (username, current_money)) for i in range(20359, 20370): s.get('https://www.hostloc.com/space-uid-%s.html' % i, headers=headers) new_money = s.get('https://www.hostloc.com/home.php?mod=spacecp&ac=credit', headers=headers).text new_money = re.search(r'积分: (\d+).+?', new_money).group(1) print("用户%s,签到后你的积分为%s" % (username, new_money))def main_handler(event, context): return start()if __name__ == '__main__': start()[/ol]复制代码 |
|