V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
xingshu1990
V2EX  ›  Python

Python 非常规 json 如何解析_淘宝 json

  •  
  •   xingshu1990 · 2017-03-17 15:10:34 +08:00 · 3541 次点击
    这是一个创建于 2596 天前的主题,其中的信息可能已经有所发展或是发生改变。

    python 版本: 2.7 本人能力:非程序员,有一点点喜欢 python ,想折腾一些数据采集之类的,以便今后转运营助理或者运营,方便数据记录、分析。 环境模拟:想要采集皮鞋第一页、第二页全部产品的标题、图片、价格等前端展现的内容,可能详情页也需要用代码做截图处理,可能需要采集正文和评价。 问题:淘宝里的 json 是非正常的,由于技术问题,先用 sub 替换了 jsonp232(),也不能正常解析。求前辈折腾一下。

    json 地址: https://s.taobao.com/api?_ksTS=1489731701469_231&callback=jsonp232&ajax=true&m=customized&rn=2e8936bb027bece89209046885ec042a&q=%E7%9A%AE%E9%9E%8B&imgfile=&js=1&stats_click=search_radio_all%3A1&initiative_id=staobaoz_20170317&ie=utf8&s=36&bcoffset=-3

    python 不用处理就能正常 dumps 、 load 能解析的 普通 json 淘宝 json 淘宝 json

    8 条回复    2017-03-18 14:26:30 +08:00
    fy
        1
    fy  
       2017-03-17 15:19:07 +08:00
    这个是 JSONP 的,不光是最前面有额外字符,最后面也有字符
    aegisho
        2
    aegisho  
       2017-03-17 15:25:54 +08:00
    ls +1
    地址里的 callback=jsonp232 直接改为 callback= 不就是 json 了
    xingshu1990
        3
    xingshu1990  
    OP
       2017-03-17 15:27:25 +08:00
    谢谢上面两个大神 我测试一下
    burnex
        4
    burnex  
       2017-03-17 15:27:31 +08:00
    JSONP
    xingshu1990
        7
    xingshu1990  
    OP
       2017-03-17 16:56:15 +08:00
    不一一答谢了,各位层主谢谢,搞定了。
    lslqtz
        8
    lslqtz  
       2017-03-18 14:26:30 +08:00
    @fhefh js=1 我觉得也要删
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2508 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 16:11 · PVG 00:11 · LAX 09:11 · JFK 12:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.