The HTML code below is from a website regarding movie reviews. I want to extract the Stars from the code below, which would be John C. Reilly, Sarah Silverman and Gal Gadot. How could I do this?
Code:
html_doc = """
<html>
<head>
</head>
<body>
<div class="credit_summary_item">
<h4 class="inline">Stars:</h4>
<a href="/name/nm0000604/?ref_=tt_ov_st_sm">John C. Reilly</a>,
<a href="/name/nm0798971/?ref_=tt_ov_st_sm">Sarah Silverman</a>,
<a href="/name/nm2933757/?ref_=tt_ov_st_sm">Gal Gadot</a>
<span class="ghost">|</span>
<a href="fullcredits/?ref_=tt_ov_st_sm">See full cast & crew</a> »
</div>
</body>
</html>
"""
from bs4 import BeautifulSoup
soup = BeautifulSoup(html_doc, 'html.parser')
My idea
I was going to use for loops to iterate through each div class until I found the class with text Stars, in which I could then extract the names. But I don't how I would code this as I am not too familiar with HTML syntax nor the module.