I want to extract some values from a website and the specific elements are
<div class="float_l dcMsg">
<div class="float_l" style="margin-right: 5px; min-width: 105px;">Slow Stochastic(20,5)</div>
<div class="float_l ind-color-box" style="margin-right: 5px; background: rgb(242, 38, 31);"></div>
<div class="float_l" style="margin-right: 5px; min-width: 105px;">%K: 33.996</div>
<div class="float_l ind-color-box" style="margin-right: 5px; background: rgb(0, 255, 0);"></div>
<div class="float_l" style="margin-right: 5px; min-width: 105px;">%D: 18.393</div>
</div>
The values I want are on the 4th line(i.e. 33.996) and 6th line(i.e. 18.393).
These numbers I want are actually from a dynamic chart but I don't know whether it is from javascript. The numbers will update to the latest value after I pressed a certain button on the web page and the value of the numbers from the element will change as well accordingly. Besides, when I just hover the cursor over the chart, the numbers will change.
However the web page will not be reloaded but only the part of the numbers of the page element will be changed after I press the button.
I have tried this code but it returns [ ].
import urllib
import re
htmltext = urllib.urlopen("http://www.example.com").read()
regex = '<div class="float_l" style="margin-right: 5px; min-width: 105px;">(.+?)</div>'
pattern = re.compile(regex)
results = re.findall(pattern,htmltext)
print results
I have also tried using BeautifulSoup but it also returns [ ].
import bs4 as bs
import urllib
sauce = urllib.urlopen('http://www.example.com').read()
soup = bs.BeautifulSoup(sauce,'html.parser')
results = soup.findAll('div',style='margin-right: 5px; min-width: 105px;')
print results