Comment 3 for bug 1645513

Revision history for this message
Leonard Richardson (leonardr) wrote : Re: Strange Behavior w/ find_all (name=str, string=str)

This issue can be the location of the feature request, but you're not the first person to ask for this. Issue 1366856 tracks a previous request to change the behavior of the 'find' methods when both a tag and a string are provided. I rejected that request for reasons I lay out in comment #2 on that issue. If you have a different idea of what you'd like Beautiful Soup to do, I'll treat it as a new request.

It looks like your use case is similar to https://bugs.launchpad.net/beautifulsoup/+bug/1518409, a second request to change the behavior of a search that provides both tag and string.

Maybe find_all("div", string="foo") should find a <div> tag if the <div> tag has a .string of "foo", _or_ it has a child that is the string "foo", _or_ it has a child with a .string of "foo". This would probably satisfy the person who filed issue 1518409, while avoiding the problems of the solution proposed in issue 1366856. It would break backwards compatibility but probably not so bad we couldn't put it in a feature release. Let me know if this is what you had in mind.