You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
 

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