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
buxiangshuo
V2EX  ›  Python

Python 爬虫抓取 Ajax 动态评论

  •  
  •   buxiangshuo · 2014-03-20 12:18:34 +08:00 · 7822 次点击
    这是一个创建于 3689 天前的主题,其中的信息可能已经有所发展或是发生改变。
    http://comment5.news.sina.com.cn/comment/skin/default.html?channel=gn&newsid=1-1-29714243

    通过chrome控制台简单粗暴得到json数据url,但是只能得到有限的评论。新浪新闻的评论都是动态加载的,不懂ajax也不太明白如何模拟header头,第一次写爬虫,真心累觉不爱啊,请哪位大神帮帮忙看下如何解决?最好详细一点,本人这方面小白一个 = _ =||

    不胜感激!!!
    10 条回复    2017-07-11 09:06:10 +08:00
    binux
        1
    binux  
       2014-03-20 12:28:02 +08:00   ❤️ 2
    不懂就去弄懂
    zoowii
        2
    zoowii  
       2014-03-20 12:29:13 +08:00
    Google
    wangfengmadking
        3
    wangfengmadking  
       2014-03-20 12:49:18 +08:00
    selenium或者PhantomJS都可以解决你的问题
    yanpeipan
        4
    yanpeipan  
       2014-03-20 14:18:34 +08:00
    python+selenium+PhantomJS
    Livid
        5
    Livid  
    MOD
       2014-03-20 14:20:25 +08:00 via iPhone   ❤️ 2
    import requests

    headers = { ... }
    url = ...
    r = requests.get(url, headers=headers)
    buxiangshuo
        6
    buxiangshuo  
    OP
       2014-03-20 16:21:49 +08:00
    感谢大家!问题已经解决啦~
    s51431980
        7
    s51431980  
       2014-03-20 16:38:59 +08:00
    @buxiangshuo 楼主怎么解决的,介绍一下思路?
    zxc337
        8
    zxc337  
       2014-03-20 17:50:22 +08:00
    怎么解决的,发我看看
    keven
        9
    keven  
       2014-03-26 00:16:49 +08:00
    解决了公布一下解决方式呗,ajax不难的,我做采集很多,用工具直接搞定
    ikeeper
        10
    ikeeper  
       2017-07-11 09:06:10 +08:00
    帖主咋弄的,求指教啊,捣鼓半天发现 js 请求后面跟了一个随机数,不知道怎么继续了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5117 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 09:40 · PVG 17:40 · LAX 02:40 · JFK 05:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.