I am trying to get a video link (on vimeo.com) using beautifulsoup. I managed to get what I wanted with the code below, but I'm trying to make it simpler and I can't...
HTML SOURCE:
<h5 class="m-b-5"><b>Devoirs </b>
</h5>
<p class="text-muted m-b-30 font-13">
N/A </p>
<h5 class="m-b-5"><b>Commentaires sur la performance </b></h5>
<p class="text-muted m-b-30 font-13">
Today finished up the writing and completed the listening assessment. Next week she'll complete the speaking and be
finished! </p>
<h5 class="m-b-5"><b>Lien vers la vidéo </b></h5>
<p class="text-muted m-b-30 font-13">
<a href="https://vimeo.com/zxzzxzx" target="_blank">https://vimeo.com/zxzxzx</a>
</p>
PYTHON CODE:
soup = BeautifulSoup(Session1.text, "lxml")
regex = re.compile('Lien vers la vidéo')
vimeolink=soup.find(string=regex).parent.parent.next_sibling.next_element.next_element.next_element.next_element
# tried the following but it's not working:
# vimeolink=soup.find(string=regex).parent('h5').find_next_sibling('a)
print(vimeolink)
result:
https://vimeo.com/zxzzxz
I tried with find_next_sibling but without success.