'How to web scrape the text under <i class>?
I'm trying to get the text "PDF file" under <i class="fa fa-file-pdf-o">. I'm using BeautifulSoup and tried the following, but it didn't work:
from bs4 import BeautifulSoup
soup = BeautifulSoup(html_doc, 'html.parser')
soup.find_all('i', class='fa fa-globe')
Here's the html I'm scraping from:
<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>
Solution 1:[1]
for x in soup.find('i'):
soup.find('i').nextSibling
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | nathan liang |
