基于python的最新电影查询

最新电影查询
import requests
import json
print('************欢迎使用电影查询系统********************')
while 1:
    city = input('输入城市名(输入0退出):')
    if city == '0':
        print('已退出电影查询系统!')
        break
    else:
        url = 'http://api.map.baidu.com/telematics/v3/movie?qt=hot_movie&location=%s&ak=TueGDhCvwI6fOrQnLM0qmXxY9N0OkOiQ&output=json'%city
        rs = requests.get(url)
        rs_dict = json.loads(rs.text)
        error_code = rs_dict['error']
        if error_code == 0:
            date = rs_dict['date']
            result = rs_dict['result']
            cityid = result['cityid']
            cityname = result['cityname']
            print('日期:%s\n城市编号:%s\n城市名:%s'%(date,cityid,cityname))
            movie = result['movie']
            for movie_dict in movie:
                movie_id =movie_dict['movie_id']
                movie_name =movie_dict['movie_name']
                movie_type =movie_dict['movie_type']
                movie_release_date =movie_dict['movie_release_date']
                movie_nation =movie_dict['movie_nation']
                movie_starring =movie_dict['movie_starring']
                movie_score =movie_dict['movie_score']
                movie_tags =movie_dict['movie_tags']
                movie_message =movie_dict['movie_message']
                print('电影编号:%s'%movie_id)
                print('电影名称:%s'%movie_name)
                print('电影类型:%s'%movie_type)
                print('上映日期:%s'%movie_release_date)
                print('出品国:%s'%movie_nation)
                print('演员:%s'%movie_starring)
                print('电影评分:%s'%movie_score)
                print('电影标签:%s'%movie_tags)
                print('电影简介:%s'%movie_message)
                print('*********************************')
        else:
            print('未查询到任何信息')

你可能感兴趣的:(基于python的最新电影查询)