Python IMDbPY – 以 XML 格式获取系列流派
在本文中,我们将了解如何获取 XML 格式的系列流派信息(信息集)。可扩展标记语言 (XML) 是一种标记语言,它定义了一组规则,用于以人类可读和机器可读的格式对文档进行编码。系列对象包含有关已记录在 IMDb 数据库中的所有剧集和季节的所有信息。
流派是任何形式或类型的任何形式的交流,随着时间的推移形成了社会认可的惯例。在系列中,有各种类型的类型,例如喜剧、恐怖、动作等。
In order to get this we have to do the following
1. Import the IMDbPY module
2. Create a instance of IMDB
3. Get the series object with the help of series ID
4. Get the XML format value here it will be in string by converting the series object into XML with the help of ‘genres’ keyword
下面是实现
Python3
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# id
code = "6468322"
# getting information
series = ia.get_movie(code)
# printing title
print(series.data['title'])
print("--------------------------------")
# converting series object's GENRES into XML file
xml = series.getAsXML('genres')
# printing some part of the XML file
print(xml[:100])
Python3
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# id
code = "6077448"
# getting information
series = ia.get_movie(code)
# printing title
print(series.data['title'])
print("--------------------------------")
# converting series object's GENRES into XML file
xml = series.getAsXML('genres')
# printing some part of the XML file
print(xml[:100])
输出 :
Money Heist
--------------------------------
另一个例子
Python3
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# id
code = "6077448"
# getting information
series = ia.get_movie(code)
# printing title
print(series.data['title'])
print("--------------------------------")
# converting series object's GENRES into XML file
xml = series.getAsXML('genres')
# printing some part of the XML file
print(xml[:100])
输出 :
Sacred Games
--------------------------------