*【艺恩娱数】Python爬虫+数据分析可视化中国影院票房*¶

文章目录

  • 一、记得登入才能看到所有的数据
  • 二、使用步骤
  • 艺恩数据可视化
  • 艺恩影院票房Top10
  • 艺恩影院票房销售额对比
  • 艺恩影院票房省份人次分析
  • 艺恩影院场次top10榜单


*【艺恩娱数】Python爬虫+数据分析可视化中国影院票房*¶_第1张图片
这个里面的影院名称,省份,城市,票房,场次,人次,平均票价,天数,场均人次这些数据都是我们需要的。

一、记得登入才能看到所有的数据

示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。

二、使用步骤

进行数据抓包

*【艺恩娱数】Python爬虫+数据分析可视化中国影院票房*¶_第2张图片
点击数据包,找我们需要的数据

*【艺恩娱数】Python爬虫+数据分析可视化中国影院票房*¶_第3张图片
借用一个工具

https://spidertools.cn/#/unQuoteUrl
*【艺恩娱数】Python爬虫+数据分析可视化中国影院票房*¶_第4张图片
*【艺恩娱数】Python爬虫+数据分析可视化中国影院票房*¶_第5张图片
*【艺恩娱数】Python爬虫+数据分析可视化中国影院票房*¶_第6张图片

import requests


headers = {
    "Accept": "application/json, text/plain, */*",
    "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
    "Connection": "keep-alive",
    "Content-Type": "application/x-www-form-urlencoded",
    "Origin": "https://ys.endata.cn",
    "Referer": "https://ys.endata.cn/BoxOffice/Org",
    "Sec-Fetch-Dest": "empty",
    "Sec-Fetch-Mode": "cors",
    "Sec-Fetch-Site": "same-origin",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
    "sec-ch-ua": "\"Google Chrome\";v=\"119\", \"Chromium\";v=\"119\", \"Not?A_Brand\";v=\"24\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\""
}
cookies = {
    "JSESSIONID": "595a72d9-2874-4819-b50e-6ae08914f501",
    "route": "65389440feb63b53ee0576493abca26d",
    "Hm_lvt_82932fc4fc199c08b9a83c4c9d02af11": "1701861215,1702188683",
    "Hm_lpvt_82932fc4fc199c08b9a83c4c9d02af11": "1702191042"
}
url = "https://ys.endata.cn/enlib-api/api/cinema/getcinemaboxoffice_day_list.do"
data = {
    "r": "0.2244452227327136",
    "bserviceprice": "0",
    "datetype": "Day",
    "date": "2023-12-09",
    "sdate": "2023-12-09",
    "edate": "2023-12-09",
    "citylevel": "",
    "lineid": "",
    "columnslist": "100,101,102,121,122,103,104,108,123,109",
    "pageindex": "3",
    "pagesize": "20",
    "order": "102",
    "ordertype": "desc"
}
response = requests.post(url, headers=headers, cookies=cookies, data=data)

print(response.text)
print(response)
{"status":1,"des":"成功","userstatus":1,"version":0,"data":{"table2":[{"TotalPage":575,"TotalCounts":11494}],"table1":[{"CinemaName":"西安高新万达广场店","ShowCount":102,"ProvinceName":"陕西省","EnbaseID":14865,"AvgBoxOffice":46.88,"CinemaID":12109,"BoxOffice":105954.52,"AudienceCount":2260,"AvgShowAudienceCount":22,"CityName":"西安市","Irank":41,"ShowDay":1},{"CinemaName":"呼和浩特万达广场店","ShowCount":53,"ProvinceName":"内蒙古","EnbaseID":2340,"AvgBoxOffice":38.11,"CinemaID":1022,"BoxOffice":105916.87,"AudienceCount":2779,"AvgShowAudienceCount":52,"CityName":"呼和浩特市","Irank":42,"ShowDay":1},{"CinemaName":"宁波博纳国际影城(北仑店)","ShowCount":76,"ProvinceName":"浙江省","EnbaseID":7529,"AvgBoxOffice":41.42,"CinemaID":6026,"BoxOffice":104799.56,"AudienceCount":2530,"AvgShowAudienceCount":33,"CityName":"宁波市","Irank":43,"ShowDay":1},{"CinemaName":"博纳国际影城秦皇岛茂业IMAX店","ShowCount":60,"ProvinceName":"河北省","EnbaseID":21036,"AvgBoxOffice":41.18,"CinemaID":16711,"BoxOffice":104507.85,"AudienceCount":2538,"AvgShowAudienceCount":42,"CityName":"秦皇岛市","Irank":44,"ShowDay":1},{"CinemaName":"星轶STARX影城(上海奉贤龙湖天街店)","ShowCount":43,"ProvinceName":"上海市","EnbaseID":22522,"AvgBoxOffice":44.63,"CinemaID":18208,"BoxOffice":103412.53,"AudienceCount":2317,"AvgShowAudienceCount":54,"CityName":"上海市","Irank":45,"ShowDay":1},{"CinemaName":"中影国际影城上海合生汇店","ShowCount":61,"ProvinceName":"上海市","EnbaseID":10384,"AvgBoxOffice":42.59,"CinemaID":9717,"BoxOffice":103369.10,"AudienceCount":2427,"AvgShowAudienceCount":40,"CityName":"上海市","Irank":46,"ShowDay":1},{"CinemaName":"广州金逸--无锡光美金逸影城","ShowCount":64,"ProvinceName":"江苏省","EnbaseID":7203,"AvgBoxOffice":39.23,"CinemaID":5712,"BoxOffice":103106.84,"AudienceCount":2628,"AvgShowAudienceCount":41,"CityName":"无锡市","Irank":47,"ShowDay":1},{"CinemaName":"SFC上影影城(北京大兴龙湖店)","ShowCount":55,"ProvinceName":"北京市","EnbaseID":10499,"AvgBoxOffice":37.00,"CinemaID":9850,"BoxOffice":102086.96,"AudienceCount":2759,"AvgShowAudienceCount":50,"CityName":"北京市","Irank":48,"ShowDay":1},{"CinemaName":"上海市星轶影城闵行天街旗舰店","ShowCount":53,"ProvinceName":"上海市","EnbaseID":19516,"AvgBoxOffice":47.67,"CinemaID":15152,"BoxOffice":102061.88,"AudienceCount":2141,"AvgShowAudienceCount":40,"CityName":"上海市","Irank":49,"ShowDay":1},{"CinemaName":"上海百丽宫影城长宁来福士店","ShowCount":46,"ProvinceName":"上海市","EnbaseID":15513,"AvgBoxOffice":64.59,"CinemaID":12213,"BoxOffice":101786.04,"AudienceCount":1576,"AvgShowAudienceCount":34,"CityName":"上海市","Irank":50,"ShowDay":1},{"CinemaName":"广州市珠影飞扬番禺天河城影城","ShowCount":57,"ProvinceName":"广东省","EnbaseID":21053,"AvgBoxOffice":48.17,"CinemaID":16726,"BoxOffice":101393.88,"AudienceCount":2105,"AvgShowAudienceCount":37,"CityName":"广州市","Irank":51,"ShowDay":1},{"CinemaName":"首都电影院昌平店","ShowCount":52,"ProvinceName":"北京市","EnbaseID":3810,"AvgBoxOffice":53.50,"CinemaID":5290,"BoxOffice":100737.43,"AudienceCount":1883,"AvgShowAudienceCount":36,"CityName":"北京市","Irank":52,"ShowDay":1},{"CinemaName":"长沙横店潇湘王府井影城","ShowCount":67,"ProvinceName":"湖南省","EnbaseID":1165,"AvgBoxOffice":34.38,"CinemaID":1247,"BoxOffice":100708.96,"AudienceCount":2929,"AvgShowAudienceCount":44,"CityName":"长沙市","Irank":53,"ShowDay":1},{"CinemaName":"济南高新万达广场店","ShowCount":72,"ProvinceName":"山东省","EnbaseID":10438,"AvgBoxOffice":40.53,"CinemaID":9759,"BoxOffice":100179.30,"AudienceCount":2472,"AvgShowAudienceCount":34,"CityName":"济南市","Irank":54,"ShowDay":1},{"CinemaName":"巨幕影城(武汉光谷广场资本大厦店)","ShowCount":68,"ProvinceName":"湖北省","EnbaseID":5909,"AvgBoxOffice":33.37,"CinemaID":3374,"BoxOffice":97349.35,"AudienceCount":2917,"AvgShowAudienceCount":43,"CityName":"武汉市","Irank":55,"ShowDay":1},{"CinemaName":"UME影城(北京双井店)","ShowCount":56,"ProvinceName":"北京市","EnbaseID":18,"AvgBoxOffice":55.45,"CinemaID":135,"BoxOffice":96869.18,"AudienceCount":1747,"AvgShowAudienceCount":31,"CityName":"北京市","Irank":56,"ShowDay":1},{"CinemaName":"UME影城(重庆南滨店)","ShowCount":77,"ProvinceName":"重庆市","EnbaseID":11185,"AvgBoxOffice":48.63,"CinemaID":10568,"BoxOffice":95992.72,"AudienceCount":1974,"AvgShowAudienceCount":26,"CityName":"重庆市","Irank":57,"ShowDay":1},{"CinemaName":"南京幸福蓝海国际影城(江北虹悦城IMAX店)","ShowCount":73,"ProvinceName":"江苏省","EnbaseID":21649,"AvgBoxOffice":40.34,"CinemaID":17324,"BoxOffice":95392.33,"AudienceCount":2365,"AvgShowAudienceCount":32,"CityName":"南京市","Irank":58,"ShowDay":1},{"CinemaName":"太原市万象影城IMAX店","ShowCount":52,"ProvinceName":"山西省","EnbaseID":16720,"AvgBoxOffice":49.23,"CinemaID":13322,"BoxOffice":95214.68,"AudienceCount":1934,"AvgShowAudienceCount":37,"CityName":"太原市","Irank":59,"ShowDay":1},{"CinemaName":"CGV影城 东莞国贸店","ShowCount":69,"ProvinceName":"广东省","EnbaseID":18072,"AvgBoxOffice":55.25,"CinemaID":13697,"BoxOffice":94745.78,"AudienceCount":1715,"AvgShowAudienceCount":25,"CityName":"东莞市","Irank":60,"ShowDay":1}],"table0":[{"SumShowCount":342160,"SumAudienceCount":4587934,"UpTime":"18:15:09","SumAvgBoxOffice":37.07,"SumBoxOffice":170085275.43,"SumAvgShowAudienceCount":13}]}}
<Response [200]>
>>> 正在获取:1[{'影院名称': '武汉市梦时代摩尔电影城', '省份': '湖北省', '城市': '武汉市', '票房': 203700.99, '场次': 94, '人次(万)': 4889, '平均票价': 41.67, '天数': 1, '场均人次': 52}, {'影院名称': '北京耀莱成龙影城(五棵松店)', '省份': '北京市', '城市': '北京市', '票房': 193666.51, '场次': 131, '人次(万)': 4663, '平均票价': 41.53, '天数': 2, '场均人次': 36}, {'影院名称': '厦门万达影城SM广场店', '省份': '福建省', '城市': '厦门市', '票房': 170204.78, '场次': 82, '人次(万)': 3987, '平均票价': 42.69, '天数': 3, '场均人次': 49}, {'影院名称': '首都电影院西单店', '省份': '北京市', '城市': '北京市', '票房': 161626.77, '场次': 80, '人次(万)': 2593, '平均票价': 62.33, '天数': 4, '场均人次': 32}, {'影院名称': '北京寰映合生汇店', '省份': '北京市', '城市': '北京市', '票房': 153878.49, '场次': 55, '人次(万)': 2230, '平均票价': 69.0, '天数': 5, '场均人次': 41}, {'影院名称': '大连经开万达广场店', '省份': '辽宁省', '城市': '大连市', '票房': 150651.29, '场次': 78, '人次(万)': 3998, '平均票价': 37.68, '天数': 6, '场均人次': 51}, {'影院名称': '武商摩尔国际电影城', '省份': '湖北省', '城市': '武汉市', '票房': 150398.93, '场次': 109, '人次(万)': 4210, '平均票价': 35.72, '天数': 7, '场均人次': 39}, {'影院名称': '金逸北京荟聚IMAX店', '省份': '北京市', '城市': '北京市', '票房': 148916.19, '场次': 60, '人次(万)': 2642, '平均票价': 56.36, '天数': 8, '场均人次': 44}, {'影院名称': '北京通州万达广场店', '省份': '北京市', '城市': '北京市', '票房': 147026.95, '场次': 77, '人次(万)': 2561, '平均票价': 57.41, '天数': 9, '场均人次': 33}, {'影院名称': '苏州五月花蓝海影城', '省份': '江苏省', '城市': '苏州市', '票房': 141371.45, '场次': 59, '人次(万)': 1415, '平均票价': 99.91, '天数': 10, '场均人次': 24}, {'影院名称': '深圳市CINESKY新天影院(壹方天地IMAX店)', '省份': '广东省', '城市': '深圳市', '票房': 140326.19, '场次': 113, '人次(万)': 2435, '平均票价': 57.63, '天数': 11, '场均人次': 22}, {'影院名称': '幸福蓝海国际影城苏州绿宝店', '省份': '江苏省', '城市': '苏州市', '票房': 139159.79, '场次': 50, '人次(万)': 1225, '平均票价': 113.6, '天数': 12, '场均人次': 25}, {'影院名称': '广州飞扬影城(正佳分店)', '省份': '广东省', '城市': '广州市', '票房': 137817.97, '场次': 55, '人次(万)': 2477, '平均票价': 55.64, '天数': 13, '场均人次': 45}, {'影院名称': '武汉市中百国际影城', '省份': '湖北省', '城市': '武汉市', '票房': 132480.05, '场次': 81, '人次(万)': 2356, '平均票价': 56.23, '天数': 14, '场均人次': 29}, {'影院名称': '广州市脉铂影城嘉禾店', '省份': '广东省', '城市': '广州市', '票房': 129773.47, '场次': 63, '人次(万)': 3313, '平均票价': 39.17, '天数': 15, '场均人次': 53}, {'影院名称': '金逸北京大悦城IMAX店', '省份': '北京市', '城市': '北京市', '票房': 127969.13, '场次': 48, '人次(万)': 2193, '平均票价': 58.35, '天数': 16, '场均人次': 46}, {'影院名称': '苏州科技文化艺术中心电影城', '省份': '江苏省', '城市': '苏州市', '票房': 127906.02, '场次': 44, '人次(万)': 750, '平均票价': 170.54, '天数': 17, '场均人次': 17}, {'影院名称': 'CGV影城 深圳壹方城店', '省份': '广东省', '城市': '深圳市', '票房': 126475.5, '场次': 70, '人次(万)': 2075, '平均票价': 60.95, '天数': 18, '场均人次': 30}, {'影院名称': '大连高新万达广场店', '省份': '辽宁省', '城市': '大连市', '票房': 126016.97, '场次': 68, '人次(万)': 3427, '平均票价': 36.77, '天数': 19, '场均人次': 50}, {'影院名称': '南昌红谷滩万达广场店', '省份': '江西省', '城市': '南昌市', '票房': 126002.4, '场次': 73, '人次(万)': 3440, '平均票价': 36.63, '天数': 20, '场均人次': 47}]

艺恩数据可视化

import pandas as pd
data=pd.read_excel("/home/mw/input/yien5551/艺恩影院票房.xlsx")
data.head(50)

*【艺恩娱数】Python爬虫+数据分析可视化中国影院票房*¶_第7张图片

data.info()

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 980 entries, 0 to 979
Data columns (total 9 columns):
影院名称     980 non-null object
省份       980 non-null object
城市       980 non-null object
票房       980 non-null float64
场次       980 non-null int64
人次()    980 non-null int64
平均票价     980 non-null float64
天数       980 non-null int64
场均人次     980 non-null int64
dtypes: float64(2), int64(4), object(3)
memory usage: 69.0+ KB
data.describe()

*【艺恩娱数】Python爬虫+数据分析可视化中国影院票房*¶_第8张图片

艺恩影院票房Top10

data_sorted = data.sort_values(by='票房', ascending=False).head(10)
data_sorted

*【艺恩娱数】Python爬虫+数据分析可视化中国影院票房*¶_第9张图片

from pyecharts.charts import Bar
from pyecharts.charts import Pie
from pyecharts.charts import Map
from pyecharts.charts import Bar, Timeline
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode  # 导入 JsCode
echarts_bar(data_sorted['影院名称'].tolist(), data_sorted['票房'].tolist(),
            data_sorted['场均人次'].tolist(), title='艺恩影院票房Top10情况对比', subtitle='票房比柱状图',
            label='票房', label2='人次')

*【艺恩娱数】Python爬虫+数据分析可视化中国影院票房*¶_第10张图片

艺恩影院票房销售额对比

customer_sale = data[['省份','人次(万)','平均票价']].groupby('省份').sum().round(2).reset_index()
customer_sale

*【艺恩娱数】Python爬虫+数据分析可视化中国影院票房*¶_第11张图片

echarts_pie(customer_sale['省份'],customer_sale['人次(万)'],title = '艺恩影院票房人次(万)对比',subtitle = ' ',label = '人次(万)')

*【艺恩娱数】Python爬虫+数据分析可视化中国影院票房*¶_第12张图片

艺恩影院票房省份人次分析

echarts_map(customer_sale['省份'].tolist(),customer_sale['人次(万)'].tolist(),title = '艺恩影院票房人次分布'
                ,subtitle = '艺恩影院票房省份人次分析',label = '人次数')

*【艺恩娱数】Python爬虫+数据分析可视化中国影院票房*¶_第13张图片

艺恩影院场次top10榜单

data_cci = data.sort_values(by='场次', ascending=False).head(10)
data_cci

*【艺恩娱数】Python爬虫+数据分析可视化中国影院票房*¶_第14张图片

echarts_line(data_cci['影院名称'].tolist(),data_cci['场次'].tolist(),title = '艺恩影院场次top10榜单',subtitle = ' ',
                label = '场次数',)

*【艺恩娱数】Python爬虫+数据分析可视化中国影院票房*¶_第15张图片
最后一个图有问题,我查看了pyecahrts的官方文档,页没有找到解决方案,y坐标数据只有一个,官方是说数据太长了,如果有大佬知道解决方案,可以给我留言,页欢迎大家一起fork项目,一起学习,一起进步

你可能感兴趣的:(python,爬虫,数据分析)