23 lines
593 B
Python
23 lines
593 B
Python
# -*- encoding:utf-8 -*-
|
|
|
|
'''
|
|
@Author : dingjiawen
|
|
@Date : 2023/12/6 19:59
|
|
@Usage :
|
|
@Desc :selenium访问页面与查找节点
|
|
'''
|
|
|
|
from selenium import webdriver
|
|
from selenium.webdriver.common.by import By
|
|
|
|
browser = webdriver.Chrome()
|
|
browser.get('https://www.taobao.com')
|
|
input_first = browser.find_element(By.ID, 'q')
|
|
input_second = browser.find_element(By.CSS_SELECTOR, '#q')
|
|
input_third = browser.find_element(By.XPATH, '//*[@id="q"]')
|
|
print(input_first, input_second, input_third)
|
|
# 多个节点
|
|
lis = browser.find_elements(By.CSS_SELECTOR,'.service-bd li')
|
|
print(lis)
|
|
browser.close()
|