常规操作
- 使用chrome切换到手机页面,参看是否有json数据。如果有会简单很多
- 抓包手机APP的软件(加密)
json模块的使用
- json.loads 字符串 – json
- json.dumps json – 字符串 //需要存入数据库时
#coding=utf-8
import json
#pprint 打印json数据时能结构化的打印出来
from pprint import pprint
teststr= '{"count": 18, "subject_collection": {"subject_count": 0, "name": "\u5f71\u9662\u70ed\u6620", "short_name": "", "collect_count": 0, "url": "https:\/\/m.douban.com\/app_topic\/movie_showing", "description": "", "type_icon_bg_text": "", "uri": "douban:\/\/douban.com\/subject_collection\/movie_showing", "cover_url": "", "updated_at": null, "icon_fg_image": "", "type_text": "", "show_header_mask": false, "mini_program_name": "", "id": "movie_showing", "more_description": "", "medium_name": "", "sharing_url": "https:\/\/www.douban.com\/doubanapp\/dispatch?uri=\/subject_collection\/movie_showing\/", "mini_program_page": "", "display": {"layout": "grid"}, "background_color_scheme": {"is_dark": true, "primary_color_light": "6f6672", "secondary_color": "f8f4f9", "primary_color_dark": "4a444c"}}, "subject_collection_items": [{"original_price": null, "rating": {"count": 1113414, "max": 10, "value": 9.3}, "cover": {"url": "https://img1.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2557573348.jpg", "width": 1080, "shape": "rectangle", "height": 1560}, "actions": [], "year": "2001", "card_subtitle": "2001 \/ \u65e5\u672c \/ \u5267\u60c5 \u52a8\u753b \u5947\u5e7b \/ \u5bab\u5d0e\u9a8f \/ \u67ca\u7460\u7f8e \u5165\u91ce\u81ea\u7531", "id": "1291561", "title": "\u5343\u4e0e\u5343\u5bfb", "comments": [{"comment": "\u6709\u90a3\u4e48\u90a3\u4e48\u7ecf\u5178\u5417\uff1f\u8fd8\u662f\u6211\u8001\u4e86\uff1f-- \u6df1\u6d77\u7684\u5fc3", "rating": {"count": 1, "max": 5, "star_count": 4, "value": 4}, "sharing_url": "https:\/\/www.douban.com\/doubanapp\/dispatch?uri=\/movie\/1291561\/interest\/82042845", "is_voted": false, "uri": "douban:\/\/douban.com\/movie\/1291561\/interest\/82042845", "platforms": [], "vote_count": 2177, "create_time": "2008-12-22 22:28:54", "status": "done", "user": {"loc": {"id": "108288", "name": "\u5317\u4eac", "uid": "beijing"}, "kind": "user", "followed": false, "name": "\u6df1\u6d77\u7684\u5fc3", "in_blacklist": false, "url": "https:\/\/www.douban.com\/people\/2093566\/", "gender": "", "remark": "", "uri": "douban:\/\/douban.com\/user\/2093566", "avatar": "https://img3.doubanio.com\/icon\/up2093566-181.jpg", "type": "user", "id": "2093566", "uid": "oceanheart"}, "id": "82042845", "wechat_timeline_share": "screenshot"}], "label": null, "actors": ["\u67ca\u7460\u7f8e", "\u5165\u91ce\u81ea\u7531", "\u590f\u6728\u771f\u7406"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u65e5\u672c \/ \u5267\u60c5 \u52a8\u753b \u5947\u5e7b \/ \u5bab\u5d0e\u9a8f \/ \u67ca\u7460\u7f8e \u5165\u91ce\u81ea\u7531", "rating_data": {"stats": [0.0010260382463053081, 0.0021553538653240607, 0.040292768900039855, 0.24886254567497937, 0.7076632933133514], "type_ranks": [{"type": "\u52a8\u753b\u7247", "rank": 0.99}, {"type": "\u5947\u5e7b\u7247", "rank": 0.99}]}, "url": "https:\/\/m.douban.com\/movie\/subject\/1291561\/", "release_date": "06.21", "original_title": "\u5343\u3068\u5343\u5c0b\u306e\u795e\u96a0\u3057", "uri": "douban:\/\/douban.com\/movie\/1291561", "subtype": "", "directors": ["\u5bab\u5d0e\u9a8f"], "reviewer_name": "", "null_rating_reason": ""}, {"original_price": null, "rating": {"count": 49073, "max": 10, "value": 8.9}, "actions": [], "year": "2019", "card_subtitle": "2019 \/ \u7f8e\u56fd \/ \u559c\u5267 \u52a8\u753b \u5947\u5e7b \/ \u4e54\u4ec0\u00b7\u5e93\u96f7 \/ \u6c64\u59c6\u00b7\u6c49\u514b\u65af \u8482\u59c6\u00b7\u827e\u4f26", "id": "6850547", "title": "\u73a9\u5177\u603b\u52a8\u54584", "label": null, "actors": ["\u6c64\u59c6\u00b7\u6c49\u514b\u65af", "\u8482\u59c6\u00b7\u827e\u4f26", "\u5b89\u59ae\u00b7\u6ce2\u8328"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u7f8e\u56fd \/ \u559c\u5267 \u52a8\u753b \u5947\u5e7b \/ \u4e54\u4ec0\u00b7\u5e93\u96f7 \/ \u6c64\u59c6\u00b7\u6c49\u514b\u65af \u8482\u59c6\u00b7\u827e\u4f26", "url": "https:\/\/m.douban.com\/movie\/subject\/6850547\/", "release_date": "06.21", "cover": {"url": "https://img3.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2557284230.jpg", "width": 1968, "shape": "rectangle", "height": 2780}, "uri": "douban:\/\/douban.com\/movie\/6850547", "subtype": "", "directors": ["\u4e54\u4ec0\u00b7\u5e93\u96f7"], "reviewer_name": "", "null_rating_reason": ""}, {"original_price": null, "rating": {"count": 57859, "max": 10, "value": 5.7}, "actions": [], "year": "2019", "card_subtitle": "2019 \/ \u7f8e\u56fd \/ \u559c\u5267 \u52a8\u4f5c \u79d1\u5e7b \/ F\u00b7\u52a0\u91cc\u00b7\u683c\u96f7 \/ \u514b\u91cc\u65af\u00b7\u6d77\u59c6\u65af\u6c83\u65af \u6cf0\u838e\u00b7\u6c64\u666e\u68ee", "id": "19971676", "title": "\u9ed1\u8863\u4eba\uff1a\u5168\u7403\u8ffd\u7f09", "label": null, "actors": ["\u514b\u91cc\u65af\u00b7\u6d77\u59c6\u65af\u6c83\u65af", "\u6cf0\u838e\u00b7\u6c64\u666e\u68ee", "\u4e3d\u8d1d\u5361\u00b7\u5f17\u683c\u68ee"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u7f8e\u56fd \/ \u559c\u5267 \u52a8\u4f5c \u79d1\u5e7b \/ F\u00b7\u52a0\u91cc\u00b7\u683c\u96f7 \/ \u514b\u91cc\u65af\u00b7\u6d77\u59c6\u65af\u6c83\u65af \u6cf0\u838e\u00b7\u6c64\u666e\u68ee", "url": "https:\/\/m.douban.com\/movie\/subject\/19971676\/", "release_date": "06.14", "cover": {"url": "https://img1.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2558701068.jpg", "width": 1800, "shape": "rectangle", "height": 2571}, "uri": "douban:\/\/douban.com\/movie\/19971676", "subtype": "", "directors": ["F\u00b7\u52a0\u91cc\u00b7\u683c\u96f7"], "reviewer_name": "", "null_rating_reason": ""}, {"original_price": null, "rating": {"count": 30956, "max": 10, "value": 8.3}, "actions": [], "year": "2017", "card_subtitle": "2017 \/ \u4fc4\u7f57\u65af \/ \u5267\u60c5 \u8fd0\u52a8 \/ \u5b89\u4e1c\u00b7\u6885\u683c\u5c14\u5b63\u5207\u592b \/ \u5f17\u62c9\u57fa\u7c73\u5c14\u00b7\u9a6c\u4ec0\u79d1\u592b \u7ea6\u7ff0\u00b7\u8428\u7ef4\u5947", "id": "27024959", "title": "\u7edd\u6740\u6155\u5c3c\u9ed1", "label": null, "actors": ["\u5f17\u62c9\u57fa\u7c73\u5c14\u00b7\u9a6c\u4ec0\u79d1\u592b", "\u7ea6\u7ff0\u00b7\u8428\u7ef4\u5947", "\u9a6c\u62c9\u7279\u00b7\u5df4\u6c99\u7f57\u592b"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u4fc4\u7f57\u65af \/ \u5267\u60c5 \u8fd0\u52a8 \/ \u5b89\u4e1c\u00b7\u6885\u683c\u5c14\u5b63\u5207\u592b \/ \u5f17\u62c9\u57fa\u7c73\u5c14\u00b7\u9a6c\u4ec0\u79d1\u592b \u7ea6\u7ff0\u00b7\u8428\u7ef4\u5947", "url": "https:\/\/m.douban.com\/movie\/subject\/27024959\/", "release_date": "06.13", "cover": {"url": "https://img3.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2556883031.jpg", "width": 846, "shape": "rectangle", "height": 1200}, "uri": "douban:\/\/douban.com\/movie\/27024959", "subtype": "", "directors": ["\u5b89\u4e1c\u00b7\u6885\u683c\u5c14\u5b63\u5207\u592b"], "reviewer_name": "", "null_rating_reason": ""}, {"original_price": null, "rating": {"count": 130347, "max": 10, "value": 6.4}, "actions": [], "year": "2019", "card_subtitle": "2019 \/ \u7f8e\u56fd \/ \u52a8\u4f5c \u79d1\u5e7b \u5192\u9669 \/ \u8fc8\u514b\u5c14\u00b7\u9053\u8d6b\u8482 \/ \u51ef\u5c14\u00b7\u94b1\u5fb7\u52d2 \u7ef4\u62c9\u00b7\u6cd5\u7c73\u52a0", "id": "25890017", "title": "\u54e5\u65af\u62c92\uff1a\u602a\u517d\u4e4b\u738b", "label": null, "actors": ["\u51ef\u5c14\u00b7\u94b1\u5fb7\u52d2", "\u7ef4\u62c9\u00b7\u6cd5\u7c73\u52a0", "\u7c73\u8389\u00b7\u6ce2\u6bd4\u00b7\u5e03\u6717"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u7f8e\u56fd \/ \u52a8\u4f5c \u79d1\u5e7b \u5192\u9669 \/ \u8fc8\u514b\u5c14\u00b7\u9053\u8d6b\u8482 \/ \u51ef\u5c14\u00b7\u94b1\u5fb7\u52d2 \u7ef4\u62c9\u00b7\u6cd5\u7c73\u52a0", "url": "https:\/\/m.douban.com\/movie\/subject\/25890017\/", "release_date": "05.31", "cover": {"url": "https://img3.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2554370800.jpg", "width": 1500, "shape": "rectangle", "height": 2150}, "uri": "douban:\/\/douban.com\/movie\/25890017", "subtype": "", "directors": ["\u8fc8\u514b\u5c14\u00b7\u9053\u8d6b\u8482"], "reviewer_name": "", "null_rating_reason": ""}, {"original_price": null, "rating": {"count": 35305, "max": 10, "value": 5.7}, "actions": [], "year": "2019", "card_subtitle": "2019 \/ \u4e2d\u56fd\u5927\u9646 \/ \u5267\u60c5 \u7231\u60c5 \/ \u7ae0\u7b1b\u6c99 \/ \u9648\u98de\u5b87 \u4f55\u84dd\u9017", "id": "26266919", "title": "\u6700\u597d\u7684\u6211\u4eec", "label": null, "actors": ["\u9648\u98de\u5b87", "\u4f55\u84dd\u9017", "\u60e0\u82f1\u7ea2"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u4e2d\u56fd\u5927\u9646 \/ \u5267\u60c5 \u7231\u60c5 \/ \u7ae0\u7b1b\u6c99 \/ \u9648\u98de\u5b87 \u4f55\u84dd\u9017", "url": "https:\/\/m.douban.com\/movie\/subject\/26266919\/", "release_date": "06.06", "cover": {"url": "https://img3.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2557157554.jpg", "width": 1286, "shape": "rectangle", "height": 1800}, "uri": "douban:\/\/douban.com\/movie\/26266919", "subtype": "", "directors": ["\u7ae0\u7b1b\u6c99"], "reviewer_name": "", "null_rating_reason": ""}, {"original_price": null, "rating": {"count": 105411, "max": 10, "value": 6.0}, "actions": [], "year": "2019", "card_subtitle": "2019 \/ \u7f8e\u56fd \/ \u52a8\u4f5c \u79d1\u5e7b \u5192\u9669 \/ \u897f\u8499\u00b7\u91d1\u4f2f\u683c \/ \u82cf\u83f2\u00b7\u7279\u7eb3 \u8a79\u59c6\u65af\u00b7\u9ea6\u5361\u6c83\u4f0a", "id": "26667010", "title": "X\u6218\u8b66\uff1a\u9ed1\u51e4\u51f0", "label": null, "actors": ["\u82cf\u83f2\u00b7\u7279\u7eb3", "\u8a79\u59c6\u65af\u00b7\u9ea6\u5361\u6c83\u4f0a", "\u8fc8\u514b\u5c14\u00b7\u6cd5\u65af\u5bbe\u5fb7"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u7f8e\u56fd \/ \u52a8\u4f5c \u79d1\u5e7b \u5192\u9669 \/ \u897f\u8499\u00b7\u91d1\u4f2f\u683c \/ \u82cf\u83f2\u00b7\u7279\u7eb3 \u8a79\u59c6\u65af\u00b7\u9ea6\u5361\u6c83\u4f0a", "url": "https:\/\/m.douban.com\/movie\/subject\/26667010\/", "release_date": "06.06", "cover": {"url": "https://img3.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2555886490.jpg", "width": 4000, "shape": "rectangle", "height": 5915}, "uri": "douban:\/\/douban.com\/movie\/26667010", "subtype": "", "directors": ["\u897f\u8499\u00b7\u91d1\u4f2f\u683c"], "reviewer_name": "", "null_rating_reason": ""}, {"original_price": null, "rating": null, "actions": [], "year": "2019", "card_subtitle": "2019 \/ \u4e2d\u56fd\u5927\u9646 \/ \u60ca\u609a \u6050\u6016 \/ \u5ec9\u6d9b \/ \u9ec4\u5955 \u8303\u9038\u81e3", "id": "27073079", "title": "\u789f\u4ed9", "label": null, "actors": ["\u9ec4\u5955", "\u8303\u9038\u81e3", "\u7a0b\u5c0f\u590f"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u4e2d\u56fd\u5927\u9646 \/ \u60ca\u609a \u6050\u6016 \/ \u5ec9\u6d9b \/ \u9ec4\u5955 \u8303\u9038\u81e3", "url": "https:\/\/m.douban.com\/movie\/subject\/27073079\/", "release_date": "06.21", "cover": {"url": "https://img1.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2559111658.jpg", "width": 1143, "shape": "rectangle", "height": 1600}, "uri": "douban:\/\/douban.com\/movie\/27073079", "subtype": "", "directors": ["\u5ec9\u6d9b"], "reviewer_name": "", "null_rating_reason": "\u6682\u65e0\u8bc4\u5206"}, {"original_price": null, "rating": null, "actions": [], "year": "2019", "card_subtitle": "2019 \/ \u4e2d\u56fd\u5927\u9646 \/ \u52a8\u4f5c \u5386\u53f2 \u6218\u4e89 \/ \u9ad8\u5e0c\u5e0c \/ \u5218\u7aef\u7aef \u90b5\u5175", "id": "30463515", "title": "\u516b\u5b50", "label": null, "actors": ["\u5218\u7aef\u7aef", "\u90b5\u5175", "\u5cb3\u7ea2"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u4e2d\u56fd\u5927\u9646 \/ \u52a8\u4f5c \u5386\u53f2 \u6218\u4e89 \/ \u9ad8\u5e0c\u5e0c \/ \u5218\u7aef\u7aef \u90b5\u5175", "url": "https:\/\/m.douban.com\/movie\/subject\/30463515\/", "release_date": "06.21", "cover": {"url": "https://img3.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2557265183.jpg", "width": 857, "shape": "rectangle", "height": 1200}, "uri": "douban:\/\/douban.com\/movie\/30463515", "subtype": "", "directors": ["\u9ad8\u5e0c\u5e0c"], "reviewer_name": "", "null_rating_reason": "\u6682\u65e0\u8bc4\u5206"}, {"original_price": null, "rating": {"count": 11047, "max": 10, "value": 5.8}, "actions": [], "year": "2018", "card_subtitle": "2018 \/ \u4e2d\u56fd\u5927\u9646 \/ \u5267\u60c5 \/ \u674e\u5c11\u7ea2 \/ \u767d\u767e\u4f55 \u9ec4\u89c9", "id": "26304201", "title": "\u5988\u9601\u662f\u5ea7\u57ce", "label": null, "actors": ["\u767d\u767e\u4f55", "\u9ec4\u89c9", "\u5434\u521a"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u4e2d\u56fd\u5927\u9646 \/ \u5267\u60c5 \/ \u674e\u5c11\u7ea2 \/ \u767d\u767e\u4f55 \u9ec4\u89c9", "url": "https:\/\/m.douban.com\/movie\/subject\/26304201\/", "release_date": "06.14", "cover": {"url": "https://img3.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2557267786.jpg", "width": 5906, "shape": "rectangle", "height": 8268}, "uri": "douban:\/\/douban.com\/movie\/26304201", "subtype": "", "directors": ["\u674e\u5c11\u7ea2"], "reviewer_name": "", "null_rating_reason": ""}, {"original_price": null, "rating": {"count": 1116, "max": 10, "value": 4.1}, "actions": [], "year": "2019", "card_subtitle": "2019 \/ \u4e2d\u56fd\u5927\u9646 \u53f0\u6e7e \/ \u5267\u60c5 \u7231\u60c5 \/ \u5468\u5f64 \u4ee3\u68a6\u9896 \/ \u5b8b\u82b8\u6866 \u5b8b\u5a01\u9f99", "id": "26923506", "title": "\u6211\u7684\u9752\u6625\u90fd\u662f\u4f60", "label": null, "actors": ["\u5b8b\u82b8\u6866", "\u5b8b\u5a01\u9f99", "\u6797\u598d\u67d4"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u4e2d\u56fd\u5927\u9646 \u53f0\u6e7e \/ \u5267\u60c5 \u7231\u60c5 \/ \u5468\u5f64 \/ \u5b8b\u82b8\u6866 \u5b8b\u5a01\u9f99", "url": "https:\/\/m.douban.com\/movie\/subject\/26923506\/", "release_date": "06.21", "cover": {"url": "https://img3.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2553778873.jpg", "width": 5461, "shape": "rectangle", "height": 8192}, "uri": "douban:\/\/douban.com\/movie\/26923506", "subtype": "", "directors": ["\u5468\u5f64"], "reviewer_name": "", "null_rating_reason": ""}, {"original_price": null, "rating": {"count": 4214, "max": 10, "value": 7.3}, "actions": [], "year": "2017", "card_subtitle": "2017 \/ \u6cd5\u56fd \/ \u5267\u60c5 \/ \u6cfd\u7ef4\u5c14\u00b7\u52d2\u683c\u6717 \/ \u857e\u96c5\u00b7\u5fb7\u5415\u76d6 \u5fb7\u5c3c\u00b7\u6885\u8bfa\u8c22", "id": "26995532", "title": "\u76d1\u62a4\u98ce\u4e91", "label": null, "actors": ["\u857e\u96c5\u00b7\u5fb7\u5415\u76d6", "\u5fb7\u5c3c\u00b7\u6885\u8bfa\u8c22", "\u6258\u9a6c\u65af\u00b7\u4e54\u91cc\u4e9a"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u6cd5\u56fd \/ \u5267\u60c5 \/ \u6cfd\u7ef4\u5c14\u00b7\u52d2\u683c\u6717 \/ \u857e\u96c5\u00b7\u5fb7\u5415\u76d6 \u5fb7\u5c3c\u00b7\u6885\u8bfa\u8c22", "url": "https:\/\/m.douban.com\/movie\/subject\/26995532\/", "release_date": "06.21", "cover": {"url": "https://img3.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2560052923.jpg", "width": 950, "shape": "rectangle", "height": 1355}, "uri": "douban:\/\/douban.com\/movie\/26995532", "subtype": "", "directors": ["\u6cfd\u7ef4\u5c14\u00b7\u52d2\u683c\u6717"], "reviewer_name": "", "null_rating_reason": ""}, {"original_price": null, "rating": {"count": 27913, "max": 10, "value": 5.7}, "actions": [], "year": "2019", "card_subtitle": "2019 \/ \u9999\u6e2f \u4e2d\u56fd\u5927\u9646 \/ \u5267\u60c5 \u52a8\u4f5c \u72af\u7f6a \/ \u738b\u6676 \u5173\u667a\u8000 \/ \u6881\u5bb6\u8f89 \u53e4\u5929\u4e50", "id": "30175306", "title": "\u8ffd\u9f99\u2161", "label": null, "actors": ["\u6881\u5bb6\u8f89", "\u53e4\u5929\u4e50", "\u6797\u5bb6\u680b"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u9999\u6e2f \u4e2d\u56fd\u5927\u9646 \/ \u5267\u60c5 \u52a8\u4f5c \u72af\u7f6a \/ \u738b\u6676 \/ \u6881\u5bb6\u8f89 \u53e4\u5929\u4e50", "url": "https:\/\/m.douban.com\/movie\/subject\/30175306\/", "release_date": "06.06", "cover": {"url": "https://img3.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2558294190.jpg", "width": 5906, "shape": "rectangle", "height": 8268}, "uri": "douban:\/\/douban.com\/movie\/30175306", "subtype": "", "directors": ["\u738b\u6676"], "reviewer_name": "", "null_rating_reason": ""}, {"original_price": null, "rating": {"count": 4732, "max": 10, "value": 4.4}, "actions": [], "year": "2019", "card_subtitle": "2019 \/ \u4e2d\u56fd\u5927\u9646 \/ \u72af\u7f6a \u60ac\u7591 \/ \u674e\u6d77\u8700 \u9ec4\u5f66\u5a01 \/ \u4e25\u5c79\u5bbd \u4ee3\u65af", "id": "27090753", "title": "\u79e6\u660e\u00b7\u751f\u6b7b\u8bed\u8005", "label": null, "actors": ["\u4e25\u5c79\u5bbd", "\u4ee3\u65af", "\u803f\u4e50"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u4e2d\u56fd\u5927\u9646 \/ \u72af\u7f6a \u60ac\u7591 \/ \u674e\u6d77\u8700 \/ \u4e25\u5c79\u5bbd \u4ee3\u65af", "url": "https:\/\/m.douban.com\/movie\/subject\/27090753\/", "release_date": "06.14", "cover": {"url": "https://img3.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2558290293.jpg", "width": 2858, "shape": "rectangle", "height": 4000}, "uri": "douban:\/\/douban.com\/movie\/27090753", "subtype": "", "directors": ["\u674e\u6d77\u8700"], "reviewer_name": "", "null_rating_reason": ""}, {"original_price": null, "rating": {"count": 1105, "max": 10, "value": 5.9}, "actions": [], "year": "2018", "card_subtitle": "2018 \/ \u7f8e\u56fd \u745e\u5178 \/ \u5267\u60c5 \u72af\u7f6a \u60ac\u7591 \/ \u897f\u8499\u00b7\u51ef\u745f \/ \u76ae\u5c14\u65af\u00b7\u5e03\u9c81\u65af\u5357 \u76d6\u00b7\u76ae\u5c14\u65af", "id": "26792540", "title": "\u771f\u76f8\u6f29\u6da1", "label": null, "actors": ["\u76ae\u5c14\u65af\u00b7\u5e03\u9c81\u65af\u5357", "\u76d6\u00b7\u76ae\u5c14\u65af", "\u660e\u59ae\u00b7\u5fb7\u91cc\u5f17"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u7f8e\u56fd \u745e\u5178 \/ \u5267\u60c5 \u72af\u7f6a \u60ac\u7591 \/ \u897f\u8499\u00b7\u51ef\u745f \/ \u76ae\u5c14\u65af\u00b7\u5e03\u9c81\u65af\u5357 \u76d6\u00b7\u76ae\u5c14\u65af", "url": "https:\/\/m.douban.com\/movie\/subject\/26792540\/", "release_date": "06.21", "cover": {"url": "https://img1.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2558537498.jpg", "width": 3600, "shape": "rectangle", "height": 6000}, "uri": "douban:\/\/douban.com\/movie\/26792540", "subtype": "", "directors": ["\u897f\u8499\u00b7\u51ef\u745f"], "reviewer_name": "", "null_rating_reason": ""}, {"original_price": null, "rating": {"count": 11881, "max": 10, "value": 7.1}, "actions": [], "year": "2017", "card_subtitle": "2017 \/ \u5370\u5ea6 \/ \u52a8\u4f5c \u72af\u7f6a \u60ac\u7591 \/ \u6851\u5409\u00b7\u53e4\u666e\u5854 \/ \u8d6b\u91cc\u5c3c\u514b\u00b7\u7f57\u65af\u6c49 \u4e9a\u7c73\u00b7\u9ad8\u5854\u59c6", "id": "26876252", "title": "\u65e0\u6240\u4e0d\u80fd", "label": null, "actors": ["\u8d6b\u91cc\u5c3c\u514b\u00b7\u7f57\u65af\u6c49", "\u4e9a\u7c73\u00b7\u9ad8\u5854\u59c6", "\u6d1b\u5c3c\u7279\u00b7\u7f57\u4f0a"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u5370\u5ea6 \/ \u52a8\u4f5c \u72af\u7f6a \u60ac\u7591 \/ \u6851\u5409\u00b7\u53e4\u666e\u5854 \/ \u8d6b\u91cc\u5c3c\u514b\u00b7\u7f57\u65af\u6c49 \u4e9a\u7c73\u00b7\u9ad8\u5854\u59c6", "url": "https:\/\/m.douban.com\/movie\/subject\/26876252\/", "release_date": "06.05", "cover": {"url": "https://img1.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2557589889.jpg", "width": 2662, "shape": "rectangle", "height": 3500}, "uri": "douban:\/\/douban.com\/movie\/26876252", "subtype": "", "directors": ["\u6851\u5409\u00b7\u53e4\u666e\u5854"], "reviewer_name": "", "null_rating_reason": ""}, {"original_price": null, "rating": {"count": 189123, "max": 10, "value": 6.6}, "actions": [], "year": "2019", "card_subtitle": "2019 \/ \u7f8e\u56fd \u65e5\u672c \/ \u559c\u5267 \u52a8\u753b \u5947\u5e7b \/ \u7f57\u4f2f\u00b7\u83b1\u7279\u66fc \/ \u745e\u6069\u00b7\u96f7\u8bfa\u5179 \u8d3e\u65af\u8482\u65af\u00b7\u53f2\u5bc6\u65af", "id": "26835471", "title": "\u5927\u4fa6\u63a2\u76ae\u5361\u4e18", "label": null, "actors": ["\u745e\u6069\u00b7\u96f7\u8bfa\u5179", "\u8d3e\u65af\u8482\u65af\u00b7\u53f2\u5bc6\u65af", "\u51ef\u745f\u7433\u00b7\u7ebd\u987f"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u7f8e\u56fd \u65e5\u672c \/ \u559c\u5267 \u52a8\u753b \u5947\u5e7b \/ \u7f57\u4f2f\u00b7\u83b1\u7279\u66fc \/ \u745e\u6069\u00b7\u96f7\u8bfa\u5179 \u8d3e\u65af\u8482\u65af\u00b7\u53f2\u5bc6\u65af", "url": "https:\/\/m.douban.com\/movie\/subject\/26835471\/", "release_date": "05.10", "cover": {"url": "https://img1.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2555538168.jpg", "width": 1350, "shape": "rectangle", "height": 2000}, "uri": "douban:\/\/douban.com\/movie\/26835471", "subtype": "", "directors": ["\u7f57\u4f2f\u00b7\u83b1\u7279\u66fc"], "reviewer_name": "", "null_rating_reason": ""}, {"original_price": null, "rating": {"count": 3071, "max": 10, "value": 8.1}, "actions": [], "year": "2019", "card_subtitle": "2019 \/ \u4e2d\u56fd\u5927\u9646 \/ \u7eaa\u5f55\u7247 \u97f3\u4e50 \/ \u807f\u99a8 \/ \u4f50\u85e4\u5eb7\u592b \u5c0f\u51d1\u662d\u5c1a", "id": "27185648", "title": "\u5c3a\u516b\u00b7\u4e00\u58f0\u4e00\u4e16", "label": null, "actors": ["\u4f50\u85e4\u5eb7\u592b", "\u5c0f\u51d1\u662d\u5c1a", "\u8521\u9e3f\u6587"], "interest": null, "type": "movie", "forum_info": null, "description": "", "has_linewatch": false, "price": null, "date": null, "info": "\u4e2d\u56fd\u5927\u9646 \/ \u7eaa\u5f55\u7247 \u97f3\u4e50 \/ \u807f\u99a8 \/ \u4f50\u85e4\u5eb7\u592b \u5c0f\u51d1\u662d\u5c1a", "url": "https:\/\/m.douban.com\/movie\/subject\/27185648\/", "release_date": "05.31", "cover": {"url": "https://img3.doubanio.com\/view\/photo\/m_ratio_poster\/public\/p2555688403.jpg", "width": 5906, "shape": "rectangle", "height": 8268}, "uri": "douban:\/\/douban.com\/movie\/27185648", "subtype": "", "directors": ["\u807f\u99a8"], "reviewer_name": "", "null_rating_reason": ""}], "total": 36, "start": 0}'
#json.loads把json字符串转化为python类型
s = json.loads(teststr);
pprint(s)
# json.dumps能够把python类型转化为json字符串
with open("douban.json","w") as f:
f.write(json.dumps(s, ensure_ascii=False, indent=2))
- 格式化json串
- 注意以上参数,ensuer_ascii=False:
如果无任何配置,或者说使用默认配置,
输出的会是的ASCII字符吗,而不是真正的中文。
这是因为json.dumps 序列化时对中文默认使用的ascii编码。加入该参数后,输出为中文
- 注意以上参数,ensuer_ascii=False:
- indent = 2格式化输出, 意思是下一级到上一级空2行
json使用注意点
- json中的字符串都是双引号引起来的
- 如果不是双引号
- eval:能实现简单的字符串和python类型的转化
- repalce: 把单引号替换为双引号
- 如果不是双引号
- 往一个文件中写入多个json串,不再式一个json串,不能直接读取
- 一行写一个json串,按照行来读取
json.load() 与json.dump()
包含json的类文件对象。 包含read() write()方法的对象就是类文件对象