Leendert
Leendert

Reputation: 13

Getting text between HTML <a> tag with beautifull soup

I'm trying to scrape all movie names from a website.

url = 'https://www.boxofficemojo.com/year/world/2019/'
content = session.get(url, verify=False).content
soup = BeautifulSoup(content, "html.parser")
movie = soup.find('a', {'class': 'a-link-normal'})
print(movie)

With this code I get the following result

<a class="a-link-normal" href="/?ref_=bo_nb_ydw_mojologo"></a>

However when I inspect the page I get the result below. The text between the 'a' tag is what I need.

<a class="a-link-normal" href="/releasegroup/gr3511898629/?ref_=bo_ydw_table_1">Avengers: Endgame</a>

How do I retrieve it?

Upvotes: 0

Views: 47

Answers (1)

Frendom
Frendom

Reputation: 558

movie = soup.find('td', class_='a-text-left mojo-field-type-release_group')
print(movie.text)

Upvotes: 1

Related Questions