Created
June 4, 2017 01:09
-
-
Save crissilvaeng/2b26ecde121dec68fa9f96b8b7313751 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import os | |
import json | |
from marvel.marvel import Marvel | |
public_key = os.environ.get('MARVEL_API_PUBLIC_KEY') | |
private_key = os.environ.get('MARVEL_API_PRIVATE_KEY') | |
marvel_api = Marvel(public_key, private_key) | |
characters = [] | |
limit = 100 | |
offset = 0 | |
next = True | |
while next: | |
characters_wrapper = marvel_api.get_characters(limit=str(limit), offset=str(offset)) | |
if characters_wrapper.code is 200: | |
next = characters_wrapper.data.total is limit | |
characters.append(characters_wrapper.data.results) | |
with open('data.txt') as out_file: | |
json.dumps(characters, out_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment