Thanks for filing this report. The behavior you're seeing is by design. Your third search is no less specific than the first, but it's searching for a different thing.
Passing 'tag' and 'string' into a find() method makes it look for a tag whose .string value is that tag. Passing 'string' but not 'tag' makes it look for a string, not a tag.
Taking out the recursive=False in your example will illustrate this.
>>> print(head.find(string=regex))
The Dormouse's story
With recursive=True in place, no matching string is found. The string is in the document, and removing recursive=True allows find() to find it.
Thanks for filing this report. The behavior you're seeing is by design. Your third search is no less specific than the first, but it's searching for a different thing.
Passing 'tag' and 'string' into a find() method makes it look for a tag whose .string value is that tag. Passing 'string' but not 'tag' makes it look for a string, not a tag.
Taking out the recursive=False in your example will illustrate this.
>>> print(head. find(string= regex))
The Dormouse's story
With recursive=True in place, no matching string is found. The string is in the document, and removing recursive=True allows find() to find it.
This is covered in the documentation for the string argument (https:/ /www.crummy. com/software/ BeautifulSoup/ bs4/doc/ #id12)