How to web scrape the text under <i class>?

Question:

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>
Asked By: ponderwonder

||

Answers:

for _ in soup.find('i'):
     soup.find('i').nextSibling
Answered By: nathan liang