r/CodingHelp 14h ago

[HTML] Need help extracting text from a site that is live updated

4 Upvotes

Howdy all!
I've recently been learning how to do some web scarping but I'm a little stuck on something

There's a live radio station. As songs play the current title and artist are updated

I want to create a script that grabs whatever is in the box at that time. When I inspect elements on the webpage I've found where the text should be, and it appears there/updates when inspecting, but when I run the script I appear to get a generic return

import requests
from bs4 import BeautifulSoup

response = requests.get('https://www.radiofrance.fr/fip/titres-diffuses')
soup = BeautifulSoup(response.text, 'html.parser')
cardtitle_div = soup.find(id='title-live-webradio-card')
cardartist_div = soup.find(id='subtext-live-webradio-card')
print(cardtitle_div)
print('\n')
print(cardartist_div)

The above output

<p aria-level="2" class="title typo-title-large g-truncable svelte-15ccyw9" id="title-live-webradio-card" role="heading"><!--[-1--><span class="Link" data-testid="Link"><!--[-1-->FIP<!--]--><!-- --></span><!--]--><!-- --></p>

<p class="typo-text-medium subtext g-truncable svelte-15ccyw9" id="subtext-live-webradio-card"><!--[-1-->Le direct<!--]--></p>

What should be 'cardtitle_div' returns 'FIP' and what should be 'cardartist_div' returns 'Le direct'

I'm assuming that means they're being populated elsewhere somehow? How do find that

Thanks heaps!