# html_doc can read from file or url soup = BeautifulSoup(html_doc, features='lxml') print("\n".join([img['alt'] for img in soup.find_all('img', alt=True)]))