common.py 929 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. """
  2. @author: luojunhui
  3. """
  4. import hashlib
  5. def str_to_md5(strings):
  6. """
  7. 字符串转化为 md5 值
  8. :param strings:
  9. :return:
  10. """
  11. # 将字符串转换为字节
  12. original_bytes = strings.encode("utf-8")
  13. # 创建一个md5 hash对象
  14. md5_hash = hashlib.md5()
  15. # 更新hash对象,传入原始字节
  16. md5_hash.update(original_bytes)
  17. # 获取16进制形式的MD5哈希值
  18. md5_value = md5_hash.hexdigest()
  19. return md5_value
  20. def proxy():
  21. """
  22. 快代理
  23. """
  24. # 隧道域名:端口号
  25. tunnel = "j685.kdltps.com:15818"
  26. # 用户名密码方式
  27. username = "t14070979713487"
  28. password = "hqwanfvy"
  29. proxies = {
  30. "http": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": tunnel},
  31. "https": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": tunnel}
  32. }
  33. return proxies