Web Scraping contents of ::before ::after CSS Psuedo element using BeautifulSoup

Viewed 3184

I'm learning Web Scraping. I would like to know how can we fetch participants count from below element?

<li class="header-hero__stat header-hero__stat--participants">
   ::before
   "255,590 Participants"
   ::after
</li>

Code I've tried

soupy = bs(html,'lxml') 
ul = soupy.find('li',{'class':"header-hero__stats"})

returns None

Target page

1 Answers

This is not content of pseudo-elements, but text content of li node, so

li = soup.find('li',{'class':"header-hero__stat--participants"}).text

should be enough to extract '255,601 Participants'

Use .text.split()[0] to get number only

Related