IMDB python库 电影信息搜索

Getting movie ID from searched movies

# importing the module
import imdb

# creating instance of IMDb
ia = imdb.IMDb()

# name
name = "Udta punjab"

# searching the name
search = ia.search_movie(name)


# loop for printing the name and id
for i in range(len(search)):
	
	# getting the id
	id = search[i].movieID
	
	# printing it
	print(search[i]['title'] + " : " + id )

 使用ID对电影进行搜索

from imdb import IMDb
ia = IMDb()
 
the_matrix = ia.get_movie('0133093')
print the_matrix['director']
 
for person in ia.search_person('Mel Gibson'):
    print person.personID, person['name']

 

如果你想使用Python编写一个爬虫程序来爬取IMDB电影数据库,并将所爬取到的电影信息存储到一个Excel表格中,你可以按照以下步骤进行操作。 1. 首先,你需要导入所需的库,比如requests和beautifulsoup。使用requests库发送HTTP请求获取IMDB网页的HTML内容,然后使用beautifulsoup库解析HTML内容。 2. 接下来,你需要找到IMDB电影页面的URL,并使用requests库发送GET请求获取该页面的HTML内容。 3. 使用beautifulsoup库解析HTML内容,通过查找相应的标签和属性获取电影的标题、评分、导演、演员等信息。 4. 创建一个Excel表格,可以使用pandas库或者openpyxl库来实现。然后将获取到的电影信息逐行写入表格中。 5. 最后,保存Excel表格,并关闭相关的文件和连接。 需要注意的是,爬取网站数据时需要遵守网站的使用规则,避免对网站造成不必要的负担。另外,IMDB网站可能会对爬虫行为进行限制或阻止。在编写爬虫程序之前,你可以查看IMDB网站的robots.txt文件,了解是否有相关限制。 参考资料: <<使用Python进行网络爬虫开发>> <<IMDBtop250>><span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [爬取imdb资料库](https://blog.csdn.net/weixin_44239541/article/details/102703071)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Python爬虫实战,requests模块,Python实现IMDB电影top数据可视化](https://blog.csdn.net/weixin_43649691/article/details/121428709)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值