# from termcolor import colored # read_file = 'this', 'Services', 'are', 'wrong', 'Services' # l1 = ['Services'] # formattedText = [] # for same_word in read_file: # if same_word in l1: # formattedText.append(colored(same_word,'white','on_red')) # else: # formattedText.append(same_word) # print(" ".join(formattedText)) from termcolor import colored from bs4 import BeautifulSoup with open('tag_comparison.html', 'r') as tag_comp_file: tag_content = tag_comp_file.read() #automation? #find a same class html = BeautifulSoup(tag_content, 'html.parser') my_divs = html.find_all('span', {'class': 'NN'}) print(my_divs) for span in my_divs: html.new_tag('css') add_group_color = html.new_tag('div') add_group_color['class'] = 'add_group_color' add_group_color['style'] = 'border-bottom: 2px solid red);' my_divs.append(add_group_color) print(add_group_color)