import marvel
PUBLIC_KEY = '你的公钥'
PRIVATE_KEY = '你的私钥'
m = marvel.Marvel(PUBLIC_KEY, PRIVATE_KEY)
characters = m.characters
def get_hero_id(characters, name):
all_characters = characters.all(nameStartsWith=name)
# 根据名字获得角色信息,仅支持英文
ids = [i['id'] for i in all_characters['data']['results']]
names = [i['name'] for i in all_characters['data']['results']]
return ids,names
ids, names = get_hero_id(characters, 'thor')
comics = characters.comics(ids[0])
# ids[0]即1009664
print([i['title'] for i in comics['data']['results']])
结果如下:
(base) ckenddeMacBook-Pro:20190925 ckend$ python 1.py
['THOR VOL. 2: ROAD TO WAR OF THE REALMS TPB (Trade Paperback)', 'Marvel Masterworks: The Mighty Thor Vol. 18 (Hardcover)', 'King Thor (2019) #1', 'Thor Epic Collection: The Black Galaxy (Trade Paperback)', 'Thor (2018) #16', 'THOR & LOKI: BLOOD BROTHERS GALLERY EDITION HC (Hardcover)', 'Thor Of The Realms (Trade Paperback)', 'War Of The Realms Omega (2019) #1', 'Thor (2018) #15', 'The Unbeatable Squirrel Girl (2015) #46', 'Kirby Is… Mighty! King-Size (Hardcover)', 'Thor (2018) #14', 'War of the Realms (2019) #5', 'MARVEL ACTION CLASSICS: SPIDER-MAN TWO-IN-ONE 1 (2019) #1', 'Thor (2018) #13', 'Moon Girl and Devil Dinosaur (2015) #43', "Decades: Marvel in The '80s - Awesome Evolutions (Trade Paperback)", 'War of the Realms (2019) #3', 'The Art of War of the Realms (Trade Paperback)', 'Mighty Thor 3D (2019) #1']