Python貓眼電影最近上映的電影票房信息
前言
本文的文字及圖片來源于網絡,僅供學習、交流使用,不具有任何商業用途,如有問題請及時聯系我們以作處理。
PS:如有需要Python學習資料的小伙伴可以加點擊下方鏈接自行獲取
基本環境配置
python 3.6 pycharm requests csv相關模塊pip安裝即可
目標網站
數據接口
請求網頁獲取數據
import requestsurl = ’http://piaofang.maoyan.com/dashboard-ajax/movie’params = {}cookies = {}headers = {}response = requests.get(url=url, params=params, headers=headers, cookies=cookies)html_data = response.json()pprint.pprint(html_data)
解析數據
movieList = html_data[’movieList’][’list’]dit = {}for i in movieList: dit[’電影名’] = i[’movieInfo’][’movieName’] dit[’票房’] = i[’sumBoxDesc’] dit[’票房占比’] = i[’boxRate’] dit[’排片占比’] = i[’showCountRate’] dit[’上映周期’] = i[’movieInfo’][’releaseInfo’] pprint.pprint(dit)
保存數據
import csvf = open(’data.csv’, mode=’a’, encoding=’utf-8’, newline=’’)csv_write = csv.DictWriter(f, fieldnames=[’電影名’, ’票房’, ’票房占比’, ’排片占比’, ’上映周期’])csv_write.writeheader()f.close()
到此這篇關于Python貓眼電影最近上映的電影票房信息的文章就介紹到這了,更多相關Python貓眼電影電影票房信息內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!
相關文章:
1. React+umi+typeScript創建項目的過程2. Warning: require(): open_basedir restriction in effect,目錄配置open_basedir報錯問題分析3. php網絡安全中命令執行漏洞的產生及本質探究4. JSP數據交互實現過程解析5. ASP.NET Core 5.0中的Host.CreateDefaultBuilder執行過程解析6. 無線標記語言(WML)基礎之WMLScript 基礎第1/2頁7. php測試程序運行速度和頁面執行速度的代碼8. SharePoint Server 2019新特性介紹9. ASP調用WebService轉化成JSON數據,附json.min.asp10. 三個不常見的 HTML5 實用新特性簡介
