0

I want to store the text of value in a variable status
which is either Discharging or Charging

<input id="batterystatus" value="Discharging" type="hidden">

I have tried to store text in status

site="http://jiofi.local.html/"
opener=uo(site)
page=opener.read()
opener.close()
parser = bs(page, "html.parser")
status=parser.find(id='batterystatus') 
zamir
  • 2,144
  • 1
  • 11
  • 23
Nikola
  • 411
  • 1
  • 5
  • 9
  • Can you show what you have tried and didn't work? – zamir Jan 12 '20 at 16:54
  • 1
    try this: ```status = parser.find(id='batterystatus')['value']``` – vadimb Jan 12 '20 at 17:06
  • 1
    Does this answer your question? [Extracting an attribute value with beautifulsoup](https://stackoverflow.com/questions/2612548/extracting-an-attribute-value-with-beautifulsoup) – AMC Jan 12 '20 at 18:24
  • Had you done any research? It took my two seconds to find a duplicate question, never mind the actual documentation. – AMC Jan 12 '20 at 18:25

1 Answers1

1

Try this.

Print(status['value'])
KunduK
  • 32,888
  • 5
  • 17
  • 41