This is not the same as extract number from a string as beautiful soup returns a beautiful soup object.
I have a local HTML file and I have used BeautifulSoup to Print the text between the pre code tags. This is my current code.
from bs4 import BeautifulSoup
f = open('/home/stats/trade_result.html', 'r')
s = f.read()
soup = BeautifulSoup(s,"lxml") pre = soup.find_all('pre') print(pre)
This is what gets printed out:
last balance: xxxxxx (-0.07%)
buy hold: xxxxxx (-0.08%)
vs. buy hold: 0.01%
2 trades over 8 days (avg 0.25 trades/day)
win/loss: 0/1
error rate: 100.00%
]
How can I return the number (2 in this example) that is before "trades over" on the forth line down and use it as an integer later in my program?