JSON数据处理

常规操作

  • 使用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": {"coun
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值