qnloft-spider/Selenium/test.py

22 lines
1.0 KiB
Python
Raw Normal View History

2023-11-26 12:31:18 +00:00
from selenium import webdriver
# urllib3 教程https://urllib3.readthedocs.io/en/latest/user-guide.html
# selenium 教程https://www.selenium.dev/zh-cn/documentation/webdriver/getting_started/
# 下载最新的chromedriver https://chromedriver.storage.googleapis.com/index.html
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.wait import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
# 使用管理器管理驱动程序
# 管理器将驱动下载到了 /Users/renmeng/.wdm/drivers/chromedriver 目录下
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
# options = ChromeOptions()
# driver = webdriver.Chrome(options=options)
# 打开网页
driver.get("https://www.lagou.com/jobs/list_运维?city=%E6%88%90%E9%83%BD&cl=false&fromSearch=true&labelWords=&suginput=") # 打开url网页 比如 driver.get()
wait = WebDriverWait(driver, 10)
# 获取网页源码
print(driver.page_source)
driver.quit()