根据您尝试访问的网站,您可能不需要使用硒。您可以使用requests访问html。在
对于您给出的HTML,uou可以使用BeautifulSoup提取表信息,如下所示:from bs4 import BeautifulSoup
html = """
Col 1 Col 2 Col 3 Hello A number Another number there A number Another number """
soup = BeautifulSoup(html, "html.parser")
rows = []
for tr in soup.find_all('tr'):
cols = []
for td in tr.find_all(['td', 'th']):
td_text = td.get_text(strip=True)
if len(td_text):
cols.append(td_text)
rows.append(cols)
print rows
给你rows保持:
^{pr2}$
要使用requests,它将启动如下内容:import requests
response = requests.get(url)
html = response.text
如果觉得《python怎样读取网页中的文本_如何使用python和selenium读取HTML表格单元格中的文本?...》对你有帮助,请点赞、收藏,并留下你的观点哦!