From this HTML code:
<p class="description" dir="ltr">Name is a fine man. <br></p>
I'm looking for replacing "Name" using the following code:
target = soup.find_all(text="Name")
for v in target:
v.replace_with('Id')
The output I would like to have is:
<p class="description" dir="ltr">Id is a fine man. <br></p>
When I:
print target
[]
Why doesn't it find the "Name"?
Thanks!
str.replace(), Are you sure you have some text that matches it?Name. Show your HTML, and what you intend to do.soupfind anytext='Name'? Also is there any code in betweenreplace_withandprint target?soupdid not findtext='Name'and there is no code in between,