cookie_update.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Author renyupeng
  2. # coding=utf-8
  3. # @Time : 2023/2/27 2:16 下午
  4. # @Site :
  5. # @File : cookie_update.py
  6. # @Software: PyCharm
  7. # @contact: renyupeng@c-top.com.cn
  8. # @Tel 1501435553
  9. from utils.mysql_utils import MysqlUtils
  10. import redis
  11. import random
  12. class cookie_update:
  13. r = redis.Redis(host='192.168.0.99', password='', port=6379, db=0)
  14. @staticmethod
  15. def get_cookie_handler():
  16. sql = "select cookie ,phone_num from kwai_promoter.kuaishou_supply_chain_cookie where status =0"
  17. result = MysqlUtils().QueryOne(sql)[0]
  18. print(result)
  19. return result
  20. @staticmethod
  21. def update_cookie_handler(phone_num):
  22. sql = "update kwai_promoter.kuaishou_supply_chain_cookie set status=1 where phone_num={phone_num}".format(
  23. phone_num=phone_num)
  24. MysqlUtils().Operate(sql=sql, params=None, DML=True)
  25. @staticmethod
  26. def update_temporary_cookie_handler(phone_num):
  27. sql = "update kwai_promoter.kuaishou_supply_chain_cookie set status=2 where phone_num={phone_num}".format(
  28. phone_num=phone_num)
  29. MysqlUtils().Operate(sql=sql, params=None, DML=True)
  30. @staticmethod
  31. def get_coookie_to_redis():
  32. sql = "select cookie ,phone_num from kwai_promoter.kuaishou_supply_chain_cookie where status =0"
  33. results = MysqlUtils().QueryAll(sql)
  34. for result in results:
  35. cookie_update.r.zadd('kuaishou_shop_token', {result[0]: result[1]})
  36. cookie_update.r.close()
  37. @staticmethod
  38. def get_click_coookie_to_redis():
  39. sql = "select cookie ,phone_num from kwai_promoter.kuaishou_supply_chain_cookie where status =0"
  40. results = MysqlUtils().QueryAll(sql)
  41. for result in results:
  42. cookie_update.r.zadd('kuaishou_shop_click_token', {result[0]: result[1]})
  43. cookie_update.r.close()