Selenium
主要流程讲解
1、控制开启浏览器
from selenium.webdriver import Chrome, ChromeOptions # 导入类库
option = ChromeOptions() # 初始化类
option.add_experimental_option("excludeSwitches", ['enable-automation', 'enable-logging']) # 添加参数
driver = Chrome(options=option) # 模拟开浏览器
driver.get('https://m.xiaozhu.com/#') # 跳转网址
myDriver.maximize_window() # 最大化窗口
driver.title # 如果成功打印title则说明接管成功2、获取对应元素
driver.find_elements_by_class_name('list_con') # 通过class的方式获取,也可以使用其他方式
find_elements(By.XPATH,"//*[contains(@href, 'pdf')]").get_attribute('href')3、处理元素数据
4、设置等待
5、托管指定端口的浏览器
最后更新于
