In this article we will see how we can get the series cast 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 the all the episodes and seasons that has records at IMDb data base.
There are basically two ways of doing this one is to filter the series object i.e IMDbPY’s object that has information about the series then converting the filtered data into XML, this way is lengthy and complicated and the second way is by using the keyword, below is the way to do this
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 ‘cast’ keyword
Below is the implementation
# 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 CAST into XML file xml_cast = series.getAsXML('cast') # printing some part of the XML file print(xml_cast[:100]) print(xml_cast[100:200]) |
Output :
Sacred Games -------------------------------- <cast infoset="main"<person id="0451307"Saif Ali Khan</name<character id=""< name Inspector Sartaj Singh</name</character<notes</notes</current-role<current-role<character
Another example
# 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 CAST into XML file xml_cast = series.getAsXML('cast') # printing some part of the XML file print(xml_cast[:100]) |
Output :
Money Heist -------------------------------- <cast infoset="main"<person id="2216549"<nameÚrsula Corberó</name<current-role<character<name
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
Recommended Posts:
- Python IMDbPY – Getting cast of the series
- Python IMDbPY – Getting Series Countries as XML
- Python IMDbPY – Getting Series Run times as XML
- Python IMDbPY – Getting Series Genres as XML
- Python IMDbPY – Retrieving art department cast from the movie object
- Python IMDbPY – Series Information in XML format
- Python IMDbPY – Getting series details fro the series id
- Python IMDbPY – Getting series years of the series
- Python IMDbPY – Company Information in XML format
- Python IMDbPY – Person Information in XML format
- Python IMDbPY – Movies Information in XML format
- Python IMDbPY – Getting genres of the series
- Python IMDbPY – Getting rating of the series
- Python IMDbPY – Getting number of seasons in the series
- Python IMDbPY – Getting the certificates of the series
- Python IMDbPY – Getting the color info of the series
- Python IMDbPY – Getting the language codes of the series
- Python IMDbPY – Getting the country codes of the series
- Python IMDbPY – Getting the countries of the series
- Python IMDbPY – Getting run time of the series
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

