Generation

generate functionTue, 27 Dec 2022

parse HTML file for paragraphs containing the word "mergers"

def find_mergers(file): import re with open(file) as f: text = f.read() paragraphs = re.findall(r'<p>(.*?)</p>', text) mergers = [] for paragraph in paragraphs: if 'mergers' in paragraph: mergers.append(paragraph) return mergers find_mergers('html_file.txt')

Questions about programming?Chat with your personal AI assistant