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