NavigableString

21 views
Skip to first unread message

Александр К-ш

unread,
Feb 9, 2023, 8:14:28 AM2/9/23
to beautifulsoup
Hello. The IDE underlines the word NavigableString as an error. This example is taken from the official documentation https://beautiful-soup-4.readthedocs.io/en/latest/.

If you need to add a string to a document, no problem–you can pass a Python string in to append(), or you can call the NavigableString constructor:

soup = BeautifulSoup("<b></b>") tag = soup.b tag.append("Hello") new_string = NavigableString(" there") tag.append(new_string) tag # <b>Hello there.</b> tag.contents # [u'Hello', u' there']

Александр К-ш

unread,
Feb 11, 2023, 1:32:54 PM2/11/23
to beautifulsoup
I had to import.
from bs4 import NavigableString

четверг, 9 февраля 2023 г. в 18:14:28 UTC+5, Александр К-ш:

Isaac Muse

unread,
Feb 11, 2023, 3:41:17 PM2/11/23
to beautifulsoup
Yep, you need to important anything you reference.
Reply all
Reply to author
Forward
0 new messages