Open In App

Python IMDbPY – Getting company ID from searched companies

Improve
Improve
Like Article
Like
Save
Share
Report

In this article we will see how we can get the company id from searched companies, company id is basically unique id given to each company as company name can be same but id will be distinct. We use search_company method to search companies with the same name. In order to get company id we use companyID method.

Syntax : companies[0].companyID Here companies is the list of company returned by search_movie and companies[0] refer to first element in list. Argument : It takes no argument. Return : It return string which is company ID

Below is the implementation 

Python3




# importing the module
import imdb
  
# creating instance of IMDb
ia = imdb.IMDb()
  
# name
name = "Marvel"
  
# searching the name
search = ia.search_company(name)
 
 
# loop for printing the name and id
for i in range(len(search)):
     
    # getting the id
    id = search[i].companyID
     
    # printing it
    print(search[i]['name'] + " : " + id )


Output :

Marvel Studios : 0051941
Marvel Entertainment : 0047120
Marvel Family Entertainment : 0769644
Marvel Enterprises : 0095134
Marvel Productions : 0106768
Marvel Movies : 0028071
Marvelous Productions : 0644186
Marvelous : 0497759
Marvel Animation : 0249290
Marvel Comics : 0131570
Marvel Knights : 0255123
Marvel.com : 0672091
Marvel Television : 0377521
Marvelous films : 0567626
Carvell Productions : 0208235
Marvel Comics Group : 0390765
Carvel : 0039046
Marvelous Mascots : 0521917
Marvee : 0345899
Marvelous 1st Studio : 0700950

Another example 

Python3




# importing the module
import imdb
  
# creating instance of IMDb
ia = imdb.IMDb()
  
# name
name = "Pixel"
  
# searching the name
search = ia.search_company(name)
 
 
# loop for printing the name and id
for i in range(len(search)):
     
    # getting the id
    id = search[i].companyID
     
    # printing it
    print(search[i]['name'] + " : " + id )


Output :

Pixel : 0022125
Pixel : 0758724
Pixel : 0445832
Pixel Magic : 0065379
Pixeldna : 0226585
Pixeleyed Pictures : 0787858
Pixelette Studios : 0335815
Pixel Brothers : 0228269
Lani Pixels : 0393856
Dilated Pixels : 0296183
PixelDog : 0436099
Pixels : 0582635
Pixel : 0405667
Big Red Pixel : 0095582
Blue Pixel : 0694611
Pixel Plus : 0395349
Zapixel : 0387827
PixelFade : 0658011
Biopixel : 0600235
Pixelpro : 0452072
?


Last Updated : 17 Jan, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads