I need help to filter html output, here the output:
button /div div div id="csrf-token-element" data-token-name="csrf_token" data-token-value="WHAT I WANT"
Is it possible to filter this out?
Thanks
CodePudding user response:
According to this screenshot in the comment, you can get the attribute value with the following snippet:
html_doc = '<div id="csrf-token-element" data-token-name="csrf_token" data-token-value="WHAT I WANT"></div>'
soup = BeautifulSoup(html_doc, "html.parser")
tag = soup.find(id="csrf-token-element")
tag.attrs["data-token-value"]