【发布时间】:2020-09-24 08:37:32
【问题描述】:
我正在尝试使用 Beautifulsoup 从 SEC 提取 form-10k。不幸的是,以下代码并未显示所有 html。它从 html 中间的某个地方开始打印。但是,当应用于我尝试过的其他几个网页时,它工作正常。任何帮助都感激不尽。我对 python 编码很陌生,我希望能学到更多,因为它开始在我身上成长:)
import urllib.request, urllib.error
from bs4 import BeautifulSoup
import ssl
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
url = "https://www.sec.gov/Archives/edgar/data/920148/000092014820000011/lh10-k2019.htm"
html = urllib.request.urlopen(url, context=ctx).read()
soup = BeautifulSoup(html, "html.parser")
print(soup.prettify().encode("utf-8"))
【问题讨论】:
-
无法复制,运行代码会打印整个页面。
-
由于我的 pycharm 控制台空间不足,它没有打印整个 html。增加缓冲区大小后,它起作用了。
标签: python html parsing beautifulsoup html-parsing