123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import json
- from xlog03 import *
- from rds_model.db_redis import DbRedis
- from log.print_log import PrintLog
- import douyin_class
- from libs.proxy import Proxy
- redisModel = DbRedis.outer_net_connect()
- if __name__ == '__main__':
- import warnings
- warnings.filterwarnings("ignore")
- print('===========注册程序===========')
- PrintLog.print('===========注册程序===========')
- rkey = 'DOUYIN_REGISTER_QUEUE'
- cur_time = int(time.time())
- while True:
- now_time = int(time.time())
- if (now_time - cur_time) > 270:
- break
- str_time = time.strftime("%H:%M:%S", time.localtime())
- try:
- llen = redisModel.llen(rkey)
- if llen < 50:
- # 获取代理
- proxy = Proxy.rola_get()
- proxies = {
- "http": "http://" + proxy,
- "https": "http://" + proxy
- }
- # proxies = {
- # "http": "http://lum-customer-c_44eb09ec-zone-data_center:4jme8s5hf9x6@zproxy.lum-superproxy.io:22225",
- # "https": "http://lum-customer-c_44eb09ec-zone-data_center:4jme8s5hf9x6@zproxy.lum-superproxy.io:22225"
- # }
- print(str_time + ' 注册代理:' + str(proxies))
- PrintLog.print(str_time + ' 注册代理:' + str(proxies))
- douApi = douyin_class.DouYinApi('', proxies)
- result = douApi.register_device()
- if result['device_id'] == '0':
- continue
- print(str_time + ' 结果:' + str(result))
- PrintLog.print(str_time + ' 结果:' + str(result))
- json_data = json.dumps(result)
- redisModel.lpush(rkey, json_data)
- print(str_time + ' 注册成功')
- PrintLog.print(str_time + ' 注册成功')
- else:
- time.sleep(3)
- except Exception as e:
- print(str_time + ' 错误:' + str(e))
- PrintLog.print(str_time + ' 错误:' + str(e))
- continue
|