How to add new value to a class with lxml

not sure if its even possible tbh.. all im trying to do is dynamically edit the text.


 <aside class="banner">
            Place <span class=red>open</span></a>


reds = root.find_class("red")
for element in reds:
    *not sure what goes here*

I already have code that i can use to edit the text remotel


I know you are asking about lxml but great alternative when it comes to html files is bs4.

With bs4/BeautifulSoup it looks like this:

for element in soup.find_all("span", { "class": "red"}):
    element.string = NEW_VALUE

with open("out.html", "w") as out_file: