如何从该网页上的 Google 文档 table 中抓取数据?
How do I scrape the data from the Google Docs table on this web page?
我正在尝试使用 Python 从该网页的 table 抓取数据。
http://www.dividendyieldhunter.com/exchanged-traded-debt-issues-sorted-alphabetically/
我尝试使用请求和 bs4。我得到了原始的 HTML 但看起来数据被隐藏了。我应该尝试什么?
该特定页面正在以下代码中的 iFrame 中的 URL 加载数据:
<iframe id="pageswitcher-content" frameborder="0" marginheight="0" marginwidth="0" src="https://docs.google.com/spreadsheets/d/1_HY2XEBKcyi4STki-uUbOfr-su8CZOfpi-jM1Racwyw/pubhtml/sheet?headers=false&gid=0" style="display: block; width: 100%; height: 100%;"></iframe>
您需要进一步从 src 属性中的 URL 请求 HTML:
https://docs.google.com/spreadsheets/d/1_HY2XEBKcyi4STki-uUbOfr-su8CZOfpi-jM1Racwyw/pubhtml/sheet?headers=false&gid=0
然后你可以用 class="waffle" 抓取 table。
注意:请注意来自原始 URL 的 URL 查询参数,如下例所示。
例如,靠近末尾的 &
必须转换为单个 & 字符,以便请求模块找到正确的 URL,例如
import requests
res=requests.get("https://docs.google.com/spreadsheets/d/1_HY2XEBKcyi4STki-uUbOfr-su8CZOfpi-jM1Racwyw/pubhtml/sheet?headers=false&gid=0")
print(res.text)
我正在尝试使用 Python 从该网页的 table 抓取数据。
http://www.dividendyieldhunter.com/exchanged-traded-debt-issues-sorted-alphabetically/
我尝试使用请求和 bs4。我得到了原始的 HTML 但看起来数据被隐藏了。我应该尝试什么?
该特定页面正在以下代码中的 iFrame 中的 URL 加载数据:
<iframe id="pageswitcher-content" frameborder="0" marginheight="0" marginwidth="0" src="https://docs.google.com/spreadsheets/d/1_HY2XEBKcyi4STki-uUbOfr-su8CZOfpi-jM1Racwyw/pubhtml/sheet?headers=false&gid=0" style="display: block; width: 100%; height: 100%;"></iframe>
您需要进一步从 src 属性中的 URL 请求 HTML:
https://docs.google.com/spreadsheets/d/1_HY2XEBKcyi4STki-uUbOfr-su8CZOfpi-jM1Racwyw/pubhtml/sheet?headers=false&gid=0
然后你可以用 class="waffle" 抓取 table。
注意:请注意来自原始 URL 的 URL 查询参数,如下例所示。
例如,靠近末尾的 &
必须转换为单个 & 字符,以便请求模块找到正确的 URL,例如
import requests
res=requests.get("https://docs.google.com/spreadsheets/d/1_HY2XEBKcyi4STki-uUbOfr-su8CZOfpi-jM1Racwyw/pubhtml/sheet?headers=false&gid=0")
print(res.text)