Python IMDbPY – Getting Series Countries as XML
Last Updated :
23 Feb, 2023
In this article we will see how we can get the series countries information(info-set) in the XML format. Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. Series object contains all the information about all the episodes and seasons that has records at IMDb data base. Some series have information about the countries of their origin or countries where they are released.
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 ‘countries’ keyword
Below is the implementation
Python3
import imdb
ia = imdb.IMDb()
code = " 6468322 "
series = ia.get_movie(code)
print (series.data[ 'title' ])
print (" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ")
xml = series.getAsXML( 'countries' )
print (xml[: 100 ])
|
Output :
Money Heist
--------------------------------
<countries infoset="main"<item Spain</item</countries
Another example
Python3
import imdb
ia = imdb.IMDb()
code = " 6077448 "
series = ia.get_movie(code)
print (series.data[ 'title' ])
print (" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ")
xml = series.getAsXML( 'countries' )
print (xml[: 100 ])
|
Output :
Sacred Games
--------------------------------
<countries infoset="main"<item India</item<item United States</item</countries
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...