新手求助,python如何模拟网页按钮点击

 我来答
szwpvz
2017-01-20 · TA获得超过640个赞
知道小有建树答主
回答量:374
采纳率:0%
帮助的人:249万
展开全部

先在命令行中下载一个selenium库:

python -m pip install selenium

然后使用selenium中的webdriver来进行模拟网页点击:

from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait

sel=webdriver.Chrome() #也可换成Ie(),Firefox()等
element=sel.find_element() #在网页源码中查找元素,具体可参考http://www.aichengxu.com/python/11949.htm
element.click() #模拟对元素进行点击

如果你是Chrome用户,需要手动下载一个chromedriver.exe,这里附上,把它放入系统Path路径任意一个文件夹中即可

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式