22 lines
1.0 KiB
Python
22 lines
1.0 KiB
Python
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()
|