problem: Adding the tag

3 views
Skip to first unread message

crajesh

unread,
Nov 2, 2009, 8:49:35 AM11/2/09
to beautifulsoup
Hi

I am new in python ,i have only little knowledge in python
beatifulsoup,
I have problem, please give the solution.

This is my html program

<body>
<p> This is paragraph </p>
<p> This is 2nd paragraph </p>
This is 3rd paragraph </p>
</body>

i need to get all the data of <p> ...</p>, but one of the starting
"<p>" tag is missing in html.
so i need to add <p> tags.

how to do this in python beatifulsoup

i have use prettify() function. but it removed the endtag "</p>" and
i get the o/p like

<body>
<p> This is paragraph </p>
<p> This is 2nd paragraph </p>
This is 3rd paragraph
</body>


but i need to get o/p as follows

<body>
<p> This is paragraph </p>
<p> This is 2nd paragraph </p>
<p> This is 3rd paragraph </p>
</body>

Thanks
C.Rajesh
Reply all
Reply to author
Forward
0 new messages