selenium +xpath

#!encoding=utf-8
from lxml import etree
from selenium import webdriver

from selenium.webdriver.chrome.options import  Options
options = Options()
options.add_argument('--headless')


browser = webdriver.Chrome(options=options)

browser.get("https://www.cnblogs.com/brady-wang/")

content = browser.page_source

html = etree.HTML(content)
title = html.xpath('//*[@id="Header1_HeaderTitle"]/text()')
print(title)
browser.close()

  

posted @ 2021-11-17 15:39  brady-wang  阅读(14)  评论(0编辑  收藏  举报