使用BeautifulSoup爬取下的内容中并没有发现列表中内容,什么原因,应该如何爬取?
使用requests只能爬取静态网页,因是js动态加载的所以你得不到想要的结果,要借助selenium 才能获取表格数据。
import pandas as pd
from selenium import webdriver
options=webdriver.ChromeOptions()
options.add_argument('--headless')
driver=webdriver.Chrome(options=options)
driver.get(url)
driver.implicitly_wait(5)
df = pd.read_html(driver.page_source)[3]
print(df)