Python IMDbPY - 将信息集添加到搜索到的人
在本文中,我们将了解如何将信息集添加到搜索到的人。搜索人检索固定的数据集,没有信息集的概念。因此,person 对象的信息将比默认信息集更少。例如,如果您使用搜索方法,则结果中的 person 对象将没有许多在 person get 方法上可用的键。
为了向搜索到的人添加信息集,我们将使用update
方法。
Syntax : imdb_object.update(person_object, info = [‘biography’])
Argument : It take two argument one is the person object for which we want more information and the other is the info set i.e list of keys
Action performed : It will retrieve the info set information
下面是实现
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# name
name = "Amir khan"
# searching the name
persons = ia.search_person(name)
person = persons[0]
# getting more information
ia.update(person, info = ['biography'])
# printing biography
print(person['biography'])
输出 :
[‘Amir Khan was born on December 8, 1986 in Bolton, Lancashire, England. He has been married to Faryal Makhdoom since May 31, 2013.::Anonymous’]
另一个例子
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# name
name = "Robert Downey"
# searching the name
persons = ia.search_person(name)
person = persons[0]
# getting more information
ia.update(person, info = ['other works'])
# printing other works
print(person['other works'])
输出 :
[‘Recorded “Every Breath You Take” with Sting, and “Chances Are” with Vonda Shepard, both for the “Ally McBeal – Songs of the Heart” soundtrack.’, ‘(October 2001) Release of the music video for the single, “I Want Love, ” by Elton John, from John\’s album, “Songs From the West Coast, ” released October 1, 2001. The video was directed by Matthew Bice, and featured Robert Downey Jr., the only person to physically appear in the video, lip-syncing the entire song, in what appears to be a continuous take of one long shot where the camera follows Downey from room to room of a large empty mansion (actually the Greystone, or Doheny, Mansion in Beverly Hills, California).’, ‘(2002) Magazine advertisement for Skechers Collection footwear.’, “(2004) Promotion and limited personal appearance tour for The Route V50 (2004) film online, a twelve minute featurette he made, in 2003, for Volvo, then a division of Ford Motor Company’s Premier Automotive Group.”, “(Autumn-Winter 2004) Played the part of the basketball in a Fox Sports TV campaign. Fox recorded Downey’s voice and actually filmed his mouth, using computer graphics to superimpose it on the ball itself.”, ‘(November 23, 2004) Release of his first album, “The Futurist, ” by Sony Classical/SBMG Records (SK 92654), and consisting of eight pop ballads written and performed by Downey, and two cover songs, “Smile, ” written by Charles Chaplin, who was portrayed by Downey in the 1992 biographical film, Chaplin (1992), and “Your Move / Give Peace A Chance” medley, in part derived from the first half of the Yes song “I\’ve Seen All Good People”.’, ‘(1992) TV commercial, “Your Vote is Your Voice, ” with Robert Downey Jr. and Sarah Jessica Parker, and directed by Lawrence Bridges, for Rock The Vote.’, ‘(November 2012) TV commercial for Call of Duty: Black Ops II (2012) video game.’, ‘(March 17, 1989) Guest on “Live on Five”.’]