H
H
houne2021-12-21 02:18:48
Python
houne, 2021-12-21 02:18:48

How to get the link from content='link'?

Let's say there is an element:

<meta property="og:audio" content="https://freesound.org/data/previews/611/611605_1648170-lq.mp3" />


How do I get into a variable
https://freesound.org/data/previews/611/611605_1648170-lq.mp3

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2021-12-21
@hottabxp

from bs4 import BeautifulSoup

html = '<meta property="og:audio" content="https://freesound.org/data/previews/611/611605_1648170-lq.mp3" />'

soup = BeautifulSoup(html,"lxml")
mp3_url = soup.find('meta',property='og:audio').get('content')
print(mp3_url)

>>> https://freesound.org/data/previews/611/611605_1648170-lq.mp3

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question