📌  相关文章
📜  Python IMDbPY – XML 格式的电影信息

📅  最后修改于: 2022-05-13 01:55:28.078000             🧑  作者: Mango

Python IMDbPY – XML 格式的电影信息

在本文中,我们将了解如何获取 XML 格式的电影信息。可扩展标记语言 (XML) 是一种标记语言,它定义了一组规则,用于以人类可读和机器可读的格式对文档进行编码。

下面是实现

# importing the module
import imdb
   
# creating instance of IMDb
ia = imdb.IMDb()
   
# id
code = "1187043"
   
# getting information
movie = ia.get_movie(code)
   
# printing movie name
print(movie['title'])
  
print("--------------------------------")
  
# converting movie object into XML file
xml_file = movie.asXML()
  
# printing some part of the XML file
print(xml_file[:150])

输出 :

3 Idiots
--------------------------------

另一个例子

# importing the module
import imdb
   
# creating instance of IMDb
ia = imdb.IMDb()
   
# id
code = "4434004"
   
# getting information
movie = ia.get_movie(code)
   
# printing movie name
print(movie['title'])
  
print("--------------------------------")
  
# converting movie object into XML file
xml_file = movie.asXML()
  
# printing some part of the XML file
print(xml_file[:150])

输出 :

Udta Punjab
--------------------------------