【发布时间】:2019-11-07 23:51:06
【问题描述】:
如何使用Abbot lab 10k filing的漂亮汤从html文档中获取<text>标签
我想使用下面的代码提取<text></text>标签的所有子标签名称
from bs4 import BeautifulSoup
import urllib.request
url ='https://www.sec.gov/Archives/edgar/data/1800/000104746919000624/a2237733z10-k.htm'
htmlpage = urllib.request.urlopen(url)
soup = BeautifulSoup(htmlpage, "html.parser")
all_text = soup.find('text')
all_tags = all_text.contents
all_tags = [x.name for x in all_tags if x.name is not None]
print(all_tags)
但是我从上面的代码中得到的一些输出是['html']。
预期输出:
['p','p','p','p','p','p','div','div','font','font', etc......]
【问题讨论】:
标签: python html python-3.x beautifulsoup