You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 lines
4.6 KiB
Python

# 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
# file = open('tag_comparison.html', 'r')
file = '''<div class ="paragraph">
<span class="CD">1</span>
<span class=".">.</span>
<span class="NN">Eligibility</span>
<span class="PRP">You</span>
<span class="MD">must</span>
<span class="VB">be</span>
<span class="IN">at</span>
<span class="JJS">least</span>
<span class="CD">13</span>
<span class="NNS">years</span>
<span class="IN">of</span>
<span class="NN">age</span>
<span class="TO">to</span>
<span class="NN">access</span>
<span class="CC">or</span>
<span class="VB">use</span>
<span class="PRP$">our</span>
<span class="NNS">Services</span>
<span class=".">.</span>
<span class="IN">If</span>
<span class="PRP">you</span>
<span class="VBP">are</span>
<span class="IN">under</span>
<span class="CD">18</span>
<span class="NNS">years</span>
<span class="IN">of</span>
<span class="NN">age</span>
<span class="(">(</span>
<span class="CC">or</span>
<span class="DT">the</span>
<span class="NN">age</span>
<span class="IN">of</span>
<span class="JJ">legal</span>
<span class="NN">majority</span>
<span class="WRB">where</span>
<span class="PRP">you</span>
<span class="VBP">live</span>
<span class=")">)</span>
<span class=",">,</span>
<span class="PRP">you</span>
<span class="MD">may</span>
<span class="RB">only</span>
<span class="NN">access</span>
<span class="CC">or</span>
<span class="VB">use</span>
<span class="PRP$">our</span>
<span class="NNS">Services</span>
<span class="IN">under</span>
<span class="DT">the</span>
<span class="NN">supervision</span>
<span class="IN">of</span>
<span class="DT">a</span>
<span class="NN">parent</span>
<span class="CC">or</span>
<span class="JJ">legal</span>
<span class="NN">guardian</span>
<span class="WP">who</span>
<span class="VBZ">agrees</span>
<span class="TO">to</span>
<span class="VB">be</span>
<span class="VBN">bound</span>
<span class="IN">by</span>
<span class="DT">this</span>
<span class="NNP">Agreement</span>
<span class=".">.</span>
<span class="IN">If</span>
<span class="PRP">you</span>
<span class="VBP">are</span>
<span class="DT">a</span>
<span class="NN">parent</span>
<span class="CC">or</span>
<span class="JJ">legal</span>
<span class="NN">guardian</span>
<span class="IN">of</span>
<span class="DT">a</span>
<span class="NN">user</span>
<span class="IN">under</span>
<span class="DT">the</span>
<span class="NN">age</span>
<span class="IN">of</span>
<span class="CD">18</span>
<span class="(">(</span>
<span class="CC">or</span>
<span class="DT">the</span>
<span class="NN">age</span>
<span class="IN">of</span>
<span class="JJ">legal</span>
<span class="NN">majority</span>
<span class=")">)</span>
<span class=",">,</span>
<span class="PRP">you</span>
<span class="VBP">agree</span>
<span class="TO">to</span>
<span class="VB">be</span>
<span class="RB">fully</span>
<span class="JJ">responsible</span>
<span class="IN">for</span>
<span class="DT">the</span>
<span class="NNS">acts</span>
<span class="CC">or</span>
<span class="NNS">omissions</span>
<span class="IN">of</span>
<span class="JJ">such</span>
<span class="NN">user</span>
<span class="IN">in</span>
<span class="NN">connection</span>
<span class="IN">with</span>
<span class="PRP$">our</span>
<span class="NNS">Services</span>
<span class=".">.</span>
<span class="IN">If</span>
<span class="PRP">you</span>
<span class="VBP">are</span>
<span class="VBG">accessing</span>
<span class="CC">or</span>
<span class="VBG">using</span>
<span class="PRP$">our</span>
<span class="NNS">Services</span>
<span class="IN">on</span>
<span class="NN">behalf</span>
<span class="IN">of</span>
<span class="DT">another</span>
<span class="NN">person</span>
<span class="CC">or</span>
<span class="NN">entity</span>
<span class=",">,</span>
<span class="PRP">you</span>
<span class="VBP">represent</span>
<span class="IN">that</span>
<span class="PRP">you</span>
<span class="VBP">are</span>
<span class="VBN">authorized</span></div>
'''
#automation?
#find a same class
html = BeautifulSoup(file, '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)