Reputation: 13
I need to grab the value of the attribute value
inside this HTML element
<option value="1129070-040" data-size="US9.5" data-stock="In_Stock" data-morecomingsoon="true">
I can't seem to find a way in bs4 documentation
Upvotes: 1
Views: 38
Reputation: 4783
Based on what you included in your question you can get the value of the value
attribute using this code:
from bs4 import BeautifulSoup
html = """<option value="1129070-040" data-size="US9.5" data-stock="In_Stock" data-morecomingsoon="true">"""
soup = BeautifulSoup(html,"lxml")
value = soup.find("option")["value"]
print(value)
hope this helps
Upvotes: 1