【发布时间】:2021-01-24 18:15:24
【问题描述】:
我正在尝试从网站上的第一个表中获取数据。我在这里查看了类似的问题并尝试了许多给定的解决方案,但似乎无法找到表格并最终找到表格中的数据。
我试过了:
from bs4 import BeautifulSoup
from selenium import webdriver
driver = webdriver.Chrome('C:\\folder\\chromedriver.exe')
url = 'https://docs.microsoft.com/en-us/windows/release-information/'
driver.get(url)
tbla = driver.find_element_by_name('table') #attempt using by element name
tblb = driver.find_element_by_class_name('cells-centered') #attempt using by class name
tblc = driver.find_element_by_xpath('//*[@id="winrelinfo_container"]/table[1]') #attempt by using xpath
并尝试使用美丽的汤
html = driver.page_source
soup = BeautifulSoup(html,'html.parser')
table = soup.find("table", {"class": "cells-centered"})
print(len(table))
非常感谢任何帮助。
【问题讨论】:
标签: python selenium iframe beautifulsoup webdriverwait