推荐学习书目
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
bytenoob
V2EX  ›  Python

求问: scrapy 解析 js 有什么好的方案?

  •  
  •   bytenoob ·
    bufrr · Oct 24, 2015 · 3163 views
    This topic created in 3926 days ago, the information mentioned may be changed or developed.
    现在只能解析静态的网页内容,想请教各位 scrapy 对于动态的内容有什么好的方案?
    12 replies    2015-10-25 12:39:07 +08:00
    bdbai
        1
    bdbai  
       Oct 24, 2015 via iPhone
    简单的 AJAX 分析一下请求即可,涉及到算法的可以尝试将 JavaScript 代码用 Python 表达。实在懒的话直接操控浏览器,不过效率很低。
    est
        2
    est  
       Oct 24, 2015
    pyexecjs phantomjs
    Victor215
        3
    Victor215  
       Oct 24, 2015
    千年老问题,快成月经贴了……楼上的方法是通用的。
    ljbha007
        4
    ljbha007  
       Oct 24, 2015
    有个办法是遇到 script 标签和 js 文件 就用正则匹配 url 这样不用去管程序逻辑到底是怎样的
    bytenoob
        5
    bytenoob  
    OP
       Oct 24, 2015
    @ljbha007 有些情况这样可以,但是很多情况比如把链接放到 function 中或者 onload 这种情况就不行了
    bytenoob
        6
    bytenoob  
    OP
       Oct 24, 2015
    @bdbai 感谢回复,我研究下~
    bytenoob
        7
    bytenoob  
    OP
       Oct 24, 2015
    @est 谢谢
    ljbha007
        8
    ljbha007  
       Oct 24, 2015
    @Yc1992 那你把 onload 也加上啊
    leavic
        9
    leavic  
       Oct 24, 2015
    ajax 基本都可以查到实际查询的位置,查处后用 request 单独请求一次这个数据就行。
    PythonAnswer
        10
    PythonAnswer  
       Oct 25, 2015
    不要效率的话,模拟浏览器也没啥。对服务器也温柔。
    gaotongfei
        11
    gaotongfei  
       Oct 25, 2015 via iPad
    selenium
    berry10086
        12
    berry10086  
       Oct 25, 2015
    selenium + phantomjs
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1096 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 18:16 · PVG 02:16 · LAX 11:16 · JFK 14:16
    ♥ Do have faith in what you're doing.