以本博客selenium分类为例
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
myblog = webdriver.Chrome()
myblog.get('https://zhaolog.com/category/selenium/')
a_href = myblog.find_element(By.CLASS_NAME,'content')
# 获取元素标签的内容
att01 = a_href.get_attribute('textContent')
text_01 = a_href.text
print(text_01)
# 获取元素内的全部HTML
att02 = a_href.get_attribute('innerHTML')
print(att02)
# 获取包含选中元素的HTML
att03 = a_href.get_attribute('outerHTML')
print(att03)
# 获取该元素的标签类型
tag01 = a_href.tag_name
print(tag01)
myblog.quit()