Answer the question
In order to leave comments, you need to log in
What is the Python way to Parse a dynamic element from a POST request to a website?
import requests
from bs4 import BeautifulSoup
songsNameList = []
url = f"https://top-radio.ru/web/russkij-xit"
q = requests.get(url)
result = q.content
soup = BeautifulSoup(result, 'lxml')
songs = soup.select("#se_igra")
for song in songs:
print(song.find('span'))
songsNameList.append(song.find('span'))
Answer the question
In order to leave comments, you need to log in
As you can see on the site, the current song is obtained by a websocket connection and an ajax request to get the "What's playing now" column. If you want to get the song that is currently playing, you can make an ajax request to https://top-radio.ru/ajax , sending the request body from the site + getting the id from the page, and parsing the result:
If you want to receive information about the update in real time via websockets, connecting to wss://ws.auto-messenger.ru/app/123124 , specifying the name of the radio as the first message, you can use the "websockets" python library:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question