0
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"))
  • 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

0 Answers0