1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] python beautifulsoup new_tag: assign class as an attribute

Discussão em 'Python' iniciado por Stack, Setembro 10, 2024.

  1. Stack

    Stack Membro Participativo

    I'm new to both python and beautifulsoup, so maybe there is a simple answer I can't find.

    When I call .new_tag('name') I also can assign attributes like .new_tag('a', href='#', id='link1')

    But I can't assign class this way, because it is reserved word. Also I can't add name this way, because it's used as keyword for the tag name attribute. I know I can add them later, using tag['class'] for example, but I would like to know, is this the only way to add class to new tag? Or there is a way to do that with a single step?

    Continue reading...

Compartilhe esta Página