У меня есть html содержание в моем документе. Мне нужно заменить все теги привязки соответствующими текстами, используя BeautifulSoup
.
Мой ввод
html = '''They are also much more fuel-efficient than <a href="http://someurl.com">rockets</a>.'''
Ожидаемый вывод
"They are also much more fuel-efficient than rockets."
Вот мой код
soup = BeautifulSoup(html, 'html.parser')
for a in soup.find_all('a'):
...
replacement_string = a.string
//I get all the anchor tags here. I need to perform the replace operation here
...
//Should display 'They are also much more fuel-efficient than rockets.'
print(replaced_html_string)
Мне удалось заменить элементы тега привязки, но не сам тег.