Thanks a lot. That really fits.
On Sep 22, 11:32 pm, Jakub Jagiełło <
jab...@gmail.com> wrote:
> The problem is in "not tag.contents" which is True only for empty
> tags, but False for tags with spaces or other tags inside.
> Therefore even if you test if content string after stripping spaces is
> empty, this test is useless as it is performed only for nodes that
> already were detected as constaining no contents.
> Therefore tag.contents is useless in such situation, as empty tags can
> be detected by tag.string is None, but tags constaining other tags
> cannot be eliminated this way because tags constaining whitespaces
> would be eliminated too.
> You should look only for tags, not for any childNodes:
>
> s.findAll(lambda tag:
tag.name == 'p' and tag.find(True) is None and
> (tag.string is None or tag.string.strip()==""))
>
> --
> Jakub Jagiełło
>