【问题标题】:Missing HTML output [BeautifulSoup]缺少 HTML 输出 [BeautifulSoup]
【发布时间】:2019-10-10 04:51:33
【问题描述】:

我在 Jupyter 笔记本上使用 BeautifulSoup 来解析来自该网站 (http://www.jepoc.or.jp/hydro/index.php?_w=usData&_x=areashow3) 的 HTML 数据。我只需要表格中的数据(标题和值)。

但是,似乎解析的汤对象仅显示表头中的值,而所有表值项(例如数值)都丢失了。来自 <tr class = "rowOdd"><tr class = "rowEven"> 的数据丢失。

这是我写的代码:

import requests
r = requests.get("http://www.jepoc.or.jp/hydro/index.php?_w=usData&_x=areashow3")
print(len(r.text))

from bs4 import BeautifulSoup
soup = BeautifulSoup(r.text,"html5")
soup

【问题讨论】:

    标签: python web-scraping beautifulsoup


    【解决方案1】:

    尝试将所有内容打印到文件或将代码末尾的汤更改为

    soup.get_text()
    

    【讨论】:

      猜你喜欢
      • 2019-12-10
      • 2023-01-22
      • 2013-09-25
      • 1970-01-01
      • 2017-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-24
      相关资源
      最近更新 更多