1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import json
- from xlog03 import *
- from rds_model.db_redis import DbRedis
- from log.print_log import PrintLog
- import douyin_class
- 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:
- 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
|