简体   繁体   中英

how can i select this element in python from bs4

<time class="FH9sR Nzb55" datetime="2020-04-17T05:27:22.000Z" title="2020-04-17">4일</time>

this Html form the under code.

'''

import requests
from bs4 import BeautifulSoup
import selenium.webdriver as webdriver

url=input("url?")
driver=webdriver.Chrome()
driver.get(url)

soup=BeautifulSoup(driver.page_source,'html.parser')

time=soup.find('time')
print(time)

''''

i want to select "2020-04-17" in title ""

i used BeautifulSoup4 library how can i do?

try this:

time = soup.find('time', class_='FH9sR Nzb55').get('title')
print(time)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM