Printing of data obtained by passwording



  • url = "https://minfin.com.ua/deposits/stats/"
    response = requests.get(url)
    bs = BeautifulSoup(response.text, "lxml")
    
    maxdep = bs.find('td', class_="dtsvto-2 dVgcFk")
    print(maxdep.text)
    
    == 11.75
    

    The problem is, for example:

    maxdep = bs.find('td', class_="dtsvto-2 dVgcFk")
    

    print(maxdep.text * 2)

    == 11.7511.75

    How do maxdep become the numerical value?



  • Type conversion with checks:

    if hasattr(maxdep, "text") and maxdep.text:
        num = float(maxdep.text.replace(",", "."))
    

    PS may be wrapped if necessary num = float(maxdep.text.replace(",", ".")) try: ... except ValueError:



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2