【发布时间】:2020-10-11 19:43:21
【问题描述】:
我正在尝试从一些 SEC 文件中提取所有文本及其 URL。在遇到某些特殊类型的 URL(似乎与 XBRL 相关)之前,我可以完成大多数 URL 的工作。
url_1 我的代码有效: https://www.sec.gov/Archives/edgar/data/1044378/000156459020025525/bioc-10q_20200331.htm
url_2 我的代码不起作用: https://www.sec.gov/ix?doc=/Archives/edgar/data/1002590/000156459020020844/sgu-10q_20200331.htm
这是我的代码:
with urllib.request.urlopen(url) as url:
html = url.read()
soup = BeautifulSoup(html, "html.parser")
for table in soup.find_all("table"):
table.decompose()
for script in soup(["script", "style"]):
script.extract()
text = soup.get_text()
print (text)
我是 Python 新手,通过一些 youtube 视频了解到这一点,有人可以帮助我了解如何提取 url_2 的所有文本。
谢谢
【问题讨论】:
标签: python text-extraction xbrl