Skip to content

Instantly share code, notes, and snippets.

@crissilvaeng
Created June 4, 2017 01:09
Show Gist options
  • Save crissilvaeng/2b26ecde121dec68fa9f96b8b7313751 to your computer and use it in GitHub Desktop.
Save crissilvaeng/2b26ecde121dec68fa9f96b8b7313751 to your computer and use it in GitHub Desktop.
#!/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