【发布时间】:2021-07-20 10:08:51
【问题描述】:
我想从https://nepsealpha.com/ 中提取一个包含许多表的特定表。显示所需表格的图片。使用以下代码更改表索引不显示所需的表。索引可以从 0 更改为 12,但未显示所需的表。帮我。 Required Table Image
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from time import sleep
from bs4 import BeautifulSoup
import pandas as pd
options = Options()
options.add_argument('--allow-running-insecure-content')
options.add_argument('--ignore-certificate-errors')
options.add_argument("--headless")
options.add_argument("--disable-extensions")
options.add_argument("--disable-gpu")
driver = webdriver.Chrome(executable_path=r"C:/Users/Personal/WebDriver/chromedriver.exe", options=options)
accept_untrusted_certs = True
driver.get('https://nepsealpha.com/')
sleep(5)
soup=BeautifulSoup(driver.page_source,'lxml')
table = soup.find_all('table')[0]
df = pd.read_html(str(table),header=0)
print(df)
【问题讨论】:
标签: python-3.x selenium-webdriver web-scraping html-table