python - 我在 beautifulsoup 中找不到表
问题描述
所以我对这些东西真的很陌生,所以这可能很愚蠢。但我似乎无法弄清楚为什么这个非常基本的代码行找不到任何表格......还试图找到一个表格来基本上获取每一行。网址:https ://uwflow.com/course/cs136
from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup
my_url = "https://uwflow.com/course/cs136"
# opening up connection, grabbing the page
uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()
# html parser
page_soup = soup(page_html, "html.parser")
enter code here
table = page_soup.findAll('table')
print(table)
解决方案
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
import pandas as pd
options = Options()
options.add_argument('--headless')
driver = webdriver.Firefox(options=options)
driver.get("https://uwflow.com/course/cs136")
df = pd.read_html(driver.page_source)[0]
df.to_csv('out.csv', index=False)
driver.quit()
输出:在线查看
我已经采取了
Winter 2020
,如果你愿意的话Spring 2020
,你需要更改[0]
为[1]
推荐阅读
- python - 计算同一熊猫列中两个不同值之间的时间
- javascript - 找不到 -lDoubleConversion 的库构建失败
- bluetooth - 蓝牙地址已被使用 - 树莓派
- android-emulator - 如何在 VirtualBox 中运行 Genymotion 的虚拟设备
- jenkins - 什么可能导致 Kubernetes Jenkins slave pod 启动和挂起
- html - 按最小内容的 div 包装器宽度
- ios - 无法向数组添加内容
- amazon-web-services - aws rds 多可用区配置
- json - 展平深层嵌套的对象列表并创建一个 csv。如何?
- c++ - 本地峰值检测器 skimage.feature.peak_local_max 的 C++ 实现或类似物是什么?