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

怎么用 pyautogui 模拟鼠标点击网页上指定文字啊?

  •  
  •   jin6220 · 2018-07-17 13:34:33 +08:00 · 4599 次点击
    这是一个创建于 2102 天前的主题,其中的信息可能已经有所发展或是发生改变。
    怎么定位到网页上的文字
    比如 知乎网页上的赞同
    搜了一下好像没提到这个功能怎么写
    https://muxuezi.github.io/posts/doc-pyautogui.html
    6 条回复    2018-07-20 16:16:14 +08:00
    Phant0m
        1
    Phant0m  
       2018-07-17 13:44:30 +08:00
    chromeheadless 可以做
    jijiwaiwai
        2
    jijiwaiwai  
       2018-07-17 14:45:54 +08:00
    selenium 方便些
    AlisaDestiny
        3
    AlisaDestiny  
       2018-07-17 15:40:00 +08:00
    你要先把需要点击的文字截个图,然后用 pyautogui.locateCenterOnScreen('button.png') 方法判断 点击的位置。在去调用方法模拟点击就好了。
    sjmcefc2
        4
    sjmcefc2  
       2018-07-18 09:30:20 +08:00
    @AlisaDestiny 这种会很准确的定位吗,刚才试了一下貌似没有成功。
    nature91
        5
    nature91  
       2018-07-18 10:04:04 +08:00
    selenium 定位元素啊 简单的不能简单了
    jin6220
        6
    jin6220  
    OP
       2018-07-20 16:16:14 +08:00
    @nature91 好的 我要好好学习这个 selenium 了 看来比 pyautogui 功能多了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1438 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 17:20 · PVG 01:20 · LAX 10:20 · JFK 13:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.