Начиная с версии 4.9.0 BeautifulSoup4 изменил [0] способ работы text
prop, теперь игнорируя содержимое встроенных скриптов:
= 4.9.0 (20200405)
...
* Embedded CSS and Javascript is now stored in distinct Stylesheet and
Script tags, which are ignored by methods like get_text() since most
people don't consider this sort of content to be 'text'. This
feature is not supported by the html5lib treebuilder. [bug=1868861]
Так что теперь больше невозможно извлечь wanted text
из из html <script>wanted text</script>
с использованием soup.find('script').text
.
Каков предпочтительный способ его извлечения сейчас? Я бы предпочел не удалять <script>
и </script>
из str(script)
вручную.
[0] - https://bazaar.launchpad.net/~leonardr/beautifulsoup/bs4/view/head: / CHANGELOG