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

获取一个被打开网页中的一个 js 变量,用什么最简单

  •  
  •   quietin · Dec 14, 2015 · 4151 views
    This topic created in 3983 days ago, the information mentioned may be changed or developed.

    这个变量在 DOM 里找不到的惹,所以不能用正则匹配或者获取内容的方式,比如 window.xx

    Ghost.py试了一下,崩溃,而且为了装它要先装 PySide, 编译老费劲了

    自己先看了一下,PyQt,里面有 webkit 封装,或者PyV8好像也可以,还有调用 phantomjs 等等,但还是要来问问,有没有更简单的方法(因为懒)

    12 replies  •  2015-12-15 16:38:41 +08:00
    just1
    just1
    Dec 14, 2015 via Android
    1
    正则表达式吧
    dofy
    dofy
    Dec 15, 2015 via iPhone
    2
    需求是什么,应用场景?
    pynix
    pynix
    Dec 15, 2015
    3
    dom 里找不到应该是 XHR 获取的吧。 chrome 看看 network 呗。。。
    arsenal4
    arsenal4
    Dec 15, 2015
    4
    chrome -> Console
    imt
    imt
    Dec 15, 2015
    5
    chrome -> Console +1
    quietin
    quietin
    OP
    Dec 15, 2015
    6
    @dofy 脚本模拟登录,需要这个变量
    quietin
    quietin
    OP
    Dec 15, 2015
    7
    @taizhenhua1987
    @imt 要自动化的。。人工看就没啥意思了
    quietin
    quietin
    OP
    Dec 15, 2015
    8
    pyv8 装不上。。。谷哥也帮不了,天啊
    imt
    imt
    Dec 15, 2015
    9
    明白你的意思了,phantomjs,学习一下.必须借助 webkit,brower 组件才行吧,个人理解.
    0192
    0192
    Dec 15, 2015
    10
    quietin
    quietin
    OP
    Dec 15, 2015
    11
    @imt 是的,但是类似的库不一定能得到 Js 变量,不过我好像已经在网页中找到这个变量了,虽然得要拼装
    quietin
    quietin
    OP
    Dec 15, 2015
    12
    @imt selenium 可以直接控制 phantomjs ,很酸爽
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1194 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 17:38 · PVG 01:38 · LAX 09:38 · JFK 12:38
    ♥ Do have faith in what you're doing.