[Python] How to change the class of a HTML <div> using BeautifulSoup?

Discussão em 'Python' iniciado por Stack, Novembro 29, 2024.

  1. Stack

    Stack Membro Participativo

    I'm modifying a HTML file using Python and BeautifulSoup, and I can change the content of headers, but I couldn't find a way to change the class of a div. My goal is to turn:

    <div id="div1" class="blue_titles">test</div>


    Into:

    <div id="div1" class="green_titles">test</div>


    I looked up and down the docs, but to no avail. It's probably right in my face, but I can't find it.

    Continue reading...

Compartilhe esta Página