您不能選擇超過 %s 個話題 話題必須以字母或數字為開頭,可包含連接號 ('-') 且最長為 35 個字
此存儲庫已封存,您能瀏覽檔案及複製此存儲庫,但不能推送、建立問題及拉取請求。
 
 
 
 
 
 

31 行
724 B

  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()