Python 自动登录COC航空人生签到采集航油

  • Python 自动登录COC航空人生签到采集航油已关闭评论
  • 410 views
  • A+
所属分类:python

利用Python实现自动登录CO航空人生论坛自动签到,并自动采集航油原料。

 # -*- coding: utf-8 -*
import requests
import time #不延时可以去掉
import re
import os
import sys

n = 0 #循环次数
a = 9 #计数器
b = 0
starttime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
nowtime = ""
Current_nmoney = ""
Current_nshuijin =""
Current_nfangwu =""
Current_nkuanggong = ""
Current_nkuanggongw =""
Current_ntie =""
Current_ntong =""
Current_nyin =""
Current_njin = ""

username = 'xxxxx'  # 论坛账户
password = 'xxxxx'  # 论坛密码
login_url = 'https://bbs.hkrscoc.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1'  # post登录接口
request = requests.post(login_url, {"username": username, 'password': password})  # 登录一次,获取request
cookie = request.cookies  # 获取request里的cookie
user_info = requests.get('https://bbs.hkrscoc.com/Airlines.php', cookies=cookie).text  # 获取用户积分中心
Current_money = re.search(r'Money:  (\d+).+?', user_info).group(1)  # 积分中心使用re获取金钱
Current_shuijin = re.search(r'航油: (\d+).+?', user_info).group(1)  # 积分中心使用re获取ID
Current_fangwu = re.search(r'房屋: (\d+).+?', user_info).group(1)  # 积分中心使用re获取
Current_kuanggong = re.search(r'员工: (\d+).+?<a href', user_info).group(1)  # 积分中心使用re获取
Current_kuanggongw = re.search(r'工作中的员工:(\d+).+?', user_info).group(1)  # 积分中心使用re获取
Current_tie = re.search(r'直馏: (\d+).+?', user_info).group(1)  # 积分中心使用re获取
Current_tong = re.search(r'裂化: (\d+).+?', user_info).group(1)  # 积分中心使用re获取
Current_yin = re.search(r'加氢: (\d+).+?', user_info).group(1)  # 积分中心使用re获取
Current_jin = re.search(r'烃剂: (\d+).+?', user_info).group(1)  # 积分中心使用re获取
formhash = re.search(r'formhash=(\S{8})', user_info).group(1)  # 积分中心使用re获取
#print (time.strftime("%Y-%m-%d %H:%M:%S-------------------------------------------\r\n", time.localtime()))
#print("原始:\r\n用户%s:\r\n金币为%s\r\n航油为%s\r\n房屋为%s\r\n员工为%s,其中工作%s\r\n直馏为%s\r\n裂化为%s\r\n加氢为%s\r\n烃剂为%s\r\n--------------------------------------------------------------\r\n" % (username, Current_money,Current_shuijin, Current_fangwu, Current_kuanggong, Current_kuanggongw, Current_tie, Current_tong,Current_yin, Current_jin))

while n < 1 :
    # 正题,刷积分
#    for i in range(1, 6):
#        request1 = requests.get('https://bbs.hkrscoc.com/Airlines.php?mod=mining&op=lingqu&mineid=%s&%s' %(i, formhash), cookies=cookie)  # 访问循环id用户空间
        try:        
                if sys.platform=="win32":
                        os.system("cls")
                elif sys.platform=="linux":
                        os.system("clear")
                print ("┌──────────┬──────────┬──────────┬──────────┬──────────┐\r\n├-原始─────┼──────────┼──────────┼ %s─┤\r\n├──────────┼──────────┼──────────┼──────────┼──────────┤"%(starttime))
                nowtime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
                b+=1
                print("│ 用户:%-4s│ 金币:%-4s│ 航油:%-4s│ 房屋:%-4s│ 员工:%-4s│\r\n├──────────┼──────────┼──────────┼──────────┼──────────┤\r\n│ 工作:%-4s│ 直馏:%-4s│ 裂化:%-4s│ 加氢:%-4s│ 烃剂:%-4s│\r\n├──────────┼──────────┼──────────┼──────────┼──────────┤\r\n├-第%3s 轮─┼──────────┼──────────┼ %s─┤\r\n├──────────┼──────────┼──────────┼──────────┼──────────┤" % (username, Current_money,Current_shuijin, Current_fangwu, Current_kuanggong, Current_kuanggongw, Current_tie, Current_tong,Current_yin, Current_jin,b,nowtime))


                user_info = requests.get('https://bbs.hkrscoc.com/Airlines.php', cookies=cookie).text  # 获取用户积分中心
                a +=1
                Current_gtie = re.search(r'采集直馏: <font color="red">(\d+).+?', user_info).group(1)
                if Current_gtie != '0':
                        request1 = requests.get('https://bbs.hkrscoc.com/Airlines.php?mod=mining&op=lingqu&mineid=1&formhash=%s' %(formhash), cookies=cookie)
                        print("当前有%s直馏,正在采集\r\n" % (Current_gtie))  #
                        a=5
                Current_gtong = re.search(r'采集裂化: <font color="red">(\d+).+?', user_info).group(1)
                if Current_gtong != '0':
                        request1 = requests.get('https://bbs.hkrscoc.com/Airlines.php?mod=mining&op=lingqu&mineid=2&formhash=%s' %(formhash), cookies=cookie)
                        print("当前有%s裂化,正在采集\r\n" % (Current_gtong))  #
                        a=5
                Current_gyin = re.search(r'采集加氢: <font color="red">(\d+).+?', user_info).group(1)
                if Current_gyin != '0':
                        request1 = requests.get('https://bbs.hkrscoc.com/Airlines.php?mod=mining&op=lingqu&mineid=3&formhash=%s' %(formhash), cookies=cookie)
                        print("当前有%s加氢,正在采集\r\n" % (Current_gyin))  #
                        a=5
                Current_gjin = re.search(r'采集烃剂: <font color="red">(\d+).+?', user_info).group(1)
                if Current_gjin != '0':
                        request1 = requests.get('https://bbs.hkrscoc.com/Airlines.php?mod=mining&op=lingqu&mineid=4&formhash=%s' %(formhash), cookies=cookie)
                        print("当前有%s烃剂,正在采集\r\n" % (Current_gjin))  #
                        a=5
                if  a > 4:
                        a=0
                        Current_nmoney = re.search(r'Money:  (\d+).+?', user_info).group(1)
                        Current_nshuijin = re.search(r'航油: (\d+).+?', user_info).group(1)
                        Current_nfangwu = re.search(r'房屋: (\d+).+?', user_info).group(1)
                        Current_nkuanggong = re.search(r'员工: (\d+).+?<a href', user_info).group(1)
                        Current_nkuanggongw = re.search(r'工作中的员工:(\d+).+?', user_info).group(1)
                        Current_ntie = re.search(r'直馏: (\d+).+?', user_info).group(1)
                        Current_ntong = re.search(r'裂化: (\d+).+?', user_info).group(1)
                        Current_nyin = re.search(r'加氢: (\d+).+?', user_info).group(1)
                        Current_njin = re.search(r'烃剂: (\d+).+?', user_info).group(1)
                request3 = requests.get('https://bbs.hkrscoc.com/plugin.php?id=k_misign:sign&operation=qiandao&formhash=%s&from=insign' %(formhash), cookies=cookie)   #签到
                request4 = requests.get('https://bbs.hkrscoc.com/plugin.php?id=time&action=1', cookies=cookie)   #领奖励 
                print("│ 用户:%-4s│ 金币:%-4s│ 航油:%-4s│ 房屋:%-4s│ 员工:%-4s│\r\n├──────────┼──────────┼──────────┼──────────┼──────────┤\r\n│ 工作:%-4s│ 直馏:%-4s│ 裂化:%-4s│ 加氢:%-4s│ 烃剂:%-4s│\r\n└──────────┴──────────┴──────────┴──────────┴──────────┘" % (username, Current_nmoney,Current_nshuijin, Current_fangwu, Current_nkuanggong, Current_nkuanggongw, Current_ntie, Current_ntong,Current_nyin, Current_njin))
#                n +=1        
                time.sleep(100) #延时120秒
        except:
                try:
                        print ("出错了,按Ctrl+C停止脚本,5s后忽略错误继续执行.")
                        time.sleep(1) 
                        print ("出错了,按Ctrl+C停止脚本,4s后忽略错误继续执行.")
                        time.sleep(1)
                        print ("出错了,按Ctrl+C停止脚本,3s后忽略错误继续执行.")
                        time.sleep(1) 
                        print ("出错了,按Ctrl+C停止脚本,2s后忽略错误继续执行.")
                        time.sleep(1) 
                        print ("出错了,按Ctrl+C停止脚本,1s后忽略错误继续执行.")
                        time.sleep(1) 
                        print ("出错了,按Ctrl+C停止脚本,0s后忽略错误继续执行.")
                except KeyboardInterrupt:
                        n=1
                        print ("停止脚本执行.")
                else:
                        print ("忽略错误,继续执行.")
Python 自动登录COC航空人生签到采集航油
  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin