target = soup.find_all(text="string")
for v in target:
v.replace_with('text')
with open ('workfile.html', "wb") as f_output:
f_output.write(soup.prettify("utf-8"))
Asked
Active
Viewed 51 times
0

αԋɱҽԃ αмєяιcαη
- 11,825
- 3
- 17
- 50

Manpreet Singh Maan
- 1
- 1
- 2
-
Based on code provided, i think you are looking to replace the string within `HTML` structure itself and then write to a file ? – αԋɱҽԃ αмєяιcαη Jul 24 '21 at 08:29
-
Does this answer your question? [Python - Find text using beautifulSoup then replace in original soup variable](https://stackoverflow.com/questions/15056633/python-find-text-using-beautifulsoup-then-replace-in-original-soup-variable) – αԋɱҽԃ αмєяιcαη Jul 24 '21 at 08:30