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

关于 Python +selenium 用 jquery 获取值

  •  
  •   newmean · 2019-07-28 22:50:18 +08:00 · 1756 次点击
    这是一个创建于 1705 天前的主题,其中的信息可能已经有所发展或是发生改变。

    在页面中有这样代码

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

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

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

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

    暴力做法,等几秒再取值
    活着 webdriverwait + 一句 css 搞定
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3133 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 116ms · UTC 00:36 · PVG 08:36 · LAX 17:36 · JFK 20:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.