I am trying to scrape the movies from https://www.imdb.com/list/ls055592025/ and this is my code. It works, but is there a way to write it without the multiple .find_next() function?
import bs4
url = 'https://www.imdb.com/list/ls055592025/'
data = []
res = requests.get(url)
soup = bs4.BeautifulSoup(res.text, 'lxml')
for e in soup.find_all(attrs={'class':"lister-item mode-detail"}):
data.append({
'movie_title': e.h3.a.get_text(strip=True),
'release_date': e.h3.find_next('span').find_next('span').get_text(strip=True).strip('(').strip(')'),
'movie_duration': e.p.find_next('span').find_next('span').find_next('span').get_text(strip=True),
'movie_genre': e.p.find_next(r'span').find_next('span').find_next('span').find_next('span').find_next('span').get_text(strip=True)
})
for d in data:
print(d)```