想要从州卫生部门网站获取总数6968或县级号码。但感到沮丧,两种方法都无法解决。
from selenium import webdriver
import time
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument("--test-type")
#options.binary_location = "/usr/bin/chromium"
driver = webdriver.Chrome(options=options)
driver.get('https://coronavirus.maryland.gov/')
#county level
table=driver.find_element_by_css_selector('table.topBlackBoxText')
for row in table.find_elements_by_css_selector('tr'):
for cell in row.find_elements_by_tag_name('td'):
print(cell.text)
#NoSuchElementException
#total number
table=driver.find_elements_by_xpath("//p[@class='topBoxH1Text']")
for span in table:
print(span)
#absolute path
table=driver.find_elements_by_xpath('//*[@id="ember80"]/div/p[1]/text()[1]')