0

I need help to filter html output, here the output:

button /div div class="b-header_actions-item m-account" div id="csrf-token-element" data-token-name="csrf_token" data-token-value="WHAT I WANT"

Is it possible to filter this out?

Thanks

4
  • 1
    What output specifically do you want to get? Commented Dec 4, 2021 at 8:31
  • just after data-token-value="THIS" not more Commented Dec 4, 2021 at 8:41
  • so you want to get the value of the attribute data-token-name which is "csrf_token"? And can you please show us the HTML tag itself. It looks like that you included the XPath Commented Dec 4, 2021 at 8:45
  • wait here is a screenshot: imgur.com/a/Kfdpobv yes i want the value from data-token-value Commented Dec 4, 2021 at 8:47

1 Answer 1

1

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"]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.