ilyass
ilyass

Reputation: 21

how to recover only the text of a <a> in webscraping in python

I want to recover only the "A côté" in:

<a href="https://www.synonymeur.com/synonyme/a-cote/" title="Synonyme du mot À côté">À côté</a>

In python with beautifulsoup and requests.

Upvotes: 0

Views: 47

Answers (1)

Slybot
Slybot

Reputation: 598

To find all tag texts use following,

links = soup.find_all('a')
links_texts = [x.text for x in links]

In order to select certain tags use the "attrs" parameter in the soup.find_all function.

Upvotes: 1

Related Questions