27 lines
597 B
Python
27 lines
597 B
Python
# -*- encoding:utf-8 -*-
|
|
|
|
'''
|
|
@Author : dingjiawen
|
|
@Date : 2023/12/6 20:20
|
|
@Usage :
|
|
@Desc :获取节点信息
|
|
'''
|
|
|
|
from selenium import webdriver
|
|
from selenium.webdriver.common.by import By
|
|
|
|
browser = webdriver.Chrome()
|
|
url = 'https://spa2.scrape.center/'
|
|
browser.get(url)
|
|
logo = browser.find_element(By.CLASS_NAME, 'logo-image')
|
|
print(logo)
|
|
# 获取属性
|
|
print(logo.get_attribute('src'))
|
|
# 获取文本值
|
|
title = browser.find_element(By.CLASS_NAME, 'logo-title')
|
|
print(title.text)
|
|
# 获取ID,位置,标签名,大小
|
|
print(title.id)
|
|
print(title.location)
|
|
print(title.tag_name)
|
|
print(title.size) |