python - Replace SRC of all IMG elements using Parser -


I am exploring a way to change the SRC attribute while not using regular expressions in all IMG tags. (Want to use any out-of-box HTML parser to be included in the default Python installation) I need to reduce the source at any time:

  & lt; Img src = "cid: imagename" & gt;  

I am trying to point to all SRT tags at the CID of an attachment for a HTML email, so I will need to change the source, so it will The path or extension is only without the file name.

Python is a HTML parser in the standard library, but it is not very useful and after Python 2.6 Is downgraded from. It is really easy to do with such things: Import beautiful soup from beautiful soup imports os.path import bassem, splate soup = soup. Sufs for IMG in FINF Beautiful Soup (my_html_string) for FI & amp; End ('IMG'): Img ['src'] = 'cid:' + splitext (basename (img ['src'])) [0] my_html_string = str (soup)


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -