V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
newmean
V2EX  ›  Python

关于 Python +selenium 用 jquery 获取值

  •  
  •   newmean · Jul 28, 2019 · 2820 views
    This topic created in 2470 days ago, the information mentioned may be changed or developed.

    在页面中有这样代码

    这个 src 是用 Ajax 获取的,然后再赋值给 src.

    现在用 python+selenium 用 find_element_by_class_name("indentify_content").find_elements_by_tag_name('img')[0].get_attribute('src')

    无法获取该值,请大神们看看.

    4 replies    2019-07-29 12:14:51 +08:00
    ila
        1
    ila  
       Jul 28, 2019
    把第一步 find 的输出看看
    Leigg
        2
    Leigg  
       Jul 29, 2019 via Android
    你这个代码都不判断数组有没有数据?
    Leigg
        3
    Leigg  
       Jul 29, 2019 via Android
    直接 by css 不是更简洁,(.indentify_content[tag=img])
    congeec
        4
    congeec  
       Jul 29, 2019 via iPhone
    Ajax 注意 race condition

    暴力做法,等几秒再取值
    活着 webdriverwait + 一句 css 搞定
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2533 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 02:58 · PVG 10:58 · LAX 19:58 · JFK 22:58
    ♥ Do have faith in what you're doing.