editing a HTML file

Jean-Michel Pichavant jeanmichel at sequans.com
Thu Mar 14 14:18:35 EDT 2013


----- Original Message -----
> Hi all,
> 
> I'would like to make a script that automatically change some text in
> a
> html file.
> 
> I need to make some changes in the text of <p> tags
> 
> My question is: there is a way to just "update/substitute" the text
> in
> the html <p> tags or do i have to make a new modified copy of the
> html file?
> 
> To be clear, i'ld like to make something like this:
> 
> open html file
> for every <p> tags:
>    if "foo" in text:
>      change "foo" in "bar"
> close html file
> 
> any sample would be really appreciated
> I'm really a beginner as you can see
> 
> Thanks
> --
> http://mail.python.org/mailman/listinfo/python-list
> 

Hi,

You can use
http://www.crummy.com/software/BeautifulSoup/bs4/doc/#modifying-the-tree

Almost all functions have an example.


Cheers,

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


More information about the Python-list mailing list