如何抓取 <i class> 下的文字?
How to web scrape the text under <i class>?
我正在尝试获取 <i class="fa fa-file-pdf-o">
下的文本 "PDF file"
。我正在使用 BeautifulSoup 并尝试了以下方法,但没有用:
from bs4 import BeautifulSoup
soup = BeautifulSoup(html_doc, 'html.parser')
soup.find_all('i', class='fa fa-globe')
这是我要抓取的html:
<div class="Reports label-type-row clearfix">
::before
<span class="label-type">
<i class="fa fa-file-pdf-o">
::before
</i>
"PDF file"
</span>
::after
</div>
for x in soup.find('i'):
soup.find('i').nextSibling
我正在尝试获取 <i class="fa fa-file-pdf-o">
下的文本 "PDF file"
。我正在使用 BeautifulSoup 并尝试了以下方法,但没有用:
from bs4 import BeautifulSoup
soup = BeautifulSoup(html_doc, 'html.parser')
soup.find_all('i', class='fa fa-globe')
这是我要抓取的html:
<div class="Reports label-type-row clearfix">
::before
<span class="label-type">
<i class="fa fa-file-pdf-o">
::before
</i>
"PDF file"
</span>
::after
</div>
for x in soup.find('i'):
soup.find('i').nextSibling