Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41239

Re: editing a HTML file

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=7786d178c=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.074
X-Spam-Evidence '*H*': 0.85; '*S*': 0.00; 'beginner': 0.05; 'modified': 0.05; 'subject:file': 0.07; 'example.': 0.17; 'changes': 0.20; 'file.': 0.20; 'all,': 0.21; 'cheers,': 0.23; 'this:': 0.23; 'to:2**1': 0.23; 'script': 0.24; 'header:In-Reply- To:1': 0.25; 'question': 0.27; 'appreciated': 0.27; 'url:software': 0.29; 'url:mailman': 0.29; "i'm": 0.29; 'url:python': 0.32; 'file': 0.32; '-----': 0.32; 'url:listinfo': 0.32; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'text': 0.34; 'thanks': 0.34; 'open': 0.35; 'something': 0.35; 'there': 0.35; 'really': 0.36; 'url:org': 0.36; 'thank': 0.36; 'subject:: ': 0.38; 'store': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'url:mail': 0.40; 'you.': 0.61; 'received:194': 0.61; 'close': 0.63; 'information': 0.63; 'person,': 0.65; 'disclose': 0.69; 'notice:': 0.71; 'privileged.': 0.72; 'medium.': 0.91
X-IronPort-AV E=Sophos;i="4.84,846,1355094000"; d="scan'208";a="1287196"
X-Virus-Scanned amavisd-new at zimbra.sequans.com
Date Thu, 14 Mar 2013 19:18:35 +0100 (CET)
From Jean-Michel Pichavant <jeanmichel@sequans.com>
To Tracubik <affdfsdfdsfsd@b.com>, python-list@python.org
In-Reply-To <51421253$0$26783$4fafbaef@reader2.news.tin.it>
Subject Re: editing a HTML file
MIME-Version 1.0
X-Mailer Zimbra 7.2.2_GA_2852 (ZimbraWebClient - GC7 (Linux)/7.2.2_GA_2852)
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3316.1363285118.2939.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1363285118 news.xs4all.nl 6858 [2001:888:2000:d::a6]:51663
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41239

Show key headers only | View raw


----- 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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: editing a HTML file Jean-Michel Pichavant <jeanmichel@sequans.com> - 2013-03-14 19:18 +0100

csiph-web