您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
此仓库已存档。您可以查看文件和克隆,但不能推送或创建工单/合并请求。

123456789101112131415161718192021222324252627282930
  1. import hashlib
  2. import requests
  3. import time
  4. def main():
  5. with open("api-keys", "r") as file:
  6. lines = file.readlines()
  7. assert len(lines) == 2, "Incorrect api-keys file"
  8. public_key = lines[0].strip()
  9. private_key = lines[1].strip()
  10. url = "http://gateway.marvel.com/v1/public/comics"
  11. params = dict()
  12. params["apikey"] = public_key
  13. ts = str(time.time())
  14. to_hash = ts + private_key + public_key
  15. hasher = hashlib.md5()
  16. hasher.update(to_hash.encode())
  17. digest = hasher.hexdigest()
  18. params["ts"] = ts
  19. params["hash"] = digest
  20. response = requests.get(url, params=params)
  21. print(response.status_code)
  22. print(response.text)
  23. if __name__ == "__main__":
  24. main()