中文文档https://python-selenium-zh.readthedocs.io/zh_CN/latest/
装包:pip install selenium
下载chrome:https://www.google.cn/chrome/
下驱动:https://chromedriver.storage.googleapis.com/index.html 注意浏览器驱动 必须要和浏览器版本匹配
这是个zip包,下载下来之后,解压里面的程序文件 chromedriver.exe 到scripts路径下
跑一下看看感觉来了没有
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
browser = webdriver.Chrome()
try:
browser.get('https://www.baidu.com')
input = browser.find_element_by_id('kw')
input.send_keys('Python')
input.send_keys(Keys.ENTER)
wait = WebDriverWait(browser, 10)
wait.until(EC.presence_of_element_located((By.ID, 'content_left')))
print(browser.current_url)
print(browser.get_cookies())
print(browser.page_source)
finally:hexo
browser.close()
不可能一下就会的,慢慢来
https://blog.csdn.net/weixin_54733110/article/details/119027005 python万字博文教你玩嗨selenium库
https://mp.weixin.qq.com/s?__biz=MzI0OTc0MzAwNA==&mid=2247487680&idx=1&sn=e40947f382116ff59761f250ee45dce3 模拟登录淘宝
https://www.pianshen.com/article/345981989/ 判断元素16种方法expected_conditions
https://github.com/Python3WebSpider/Python3WebSpider/blob/master/7.1-Selenium%E7%9A%84%E4%BD%BF%E7%94%A8.md
http://www.byhy.net/tut/auto/selenium/01/这个作者写的很好
对应的网课在https://www.bilibili.com/video/av64421994/?p=1简直是保姆级教学,
希望你学会了不要乱搞
网友评论