店播爬取Python脚本

db_redis.py 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import redis
  2. class DbRedis:
  3. __connection = None
  4. __douyin_connection = None
  5. @staticmethod
  6. def connect():
  7. if DbRedis.__connection is None:
  8. host = 'r-2ze28bdb7389a8a4614.redis.rds.aliyuncs.com'
  9. port = 6379
  10. password = 'Zhuaduoduo2017'
  11. DbRedis.__connection = redis.StrictRedis(
  12. host=host,
  13. port=port,
  14. password=password,
  15. decode_responses=True
  16. )
  17. return DbRedis.__connection
  18. @staticmethod
  19. def douyin_connect():
  20. if DbRedis.__douyin_connection is None:
  21. host = 'r-2ze28bdb7389a8a4.redis.rds.aliyuncs.com'
  22. port = 6379
  23. password = 'Zhuaduoduo2017'
  24. DbRedis.__douyin_connection = redis.StrictRedis(
  25. host=host,
  26. port=port,
  27. password=password,
  28. decode_responses=True
  29. )
  30. return DbRedis.__douyin_connection
  31. @staticmethod
  32. def outer_net_connect():
  33. if DbRedis.__connection is None:
  34. host = 'r-2ze28bdb7389a8a4pd.redis.rds.aliyuncs.com'
  35. port = 6379
  36. password = 'Zhuaduoduo2017'
  37. DbRedis.__connection = redis.StrictRedis(
  38. host=host,
  39. port=port,
  40. password=password,
  41. decode_responses=True
  42. )
  43. return DbRedis.__connection