In intraday.pro there is an online status which is being updated repeatedly after a specific period of time. The element is being generated dynamically within a javascript innerHTML code.
I checked the html code with browser's Inspect Element and this is the code:
<div id="is_online">
   <font color="green">Online</font>
</div>
I use the code below but it returns None and doesn't find the online status.
from bs4 import BeautifulSoup
import requests
r = requests.get("http://intraday.pro/")
soup = BeautifulSoup(r.text, 'html.parser')
is_online = True
while is_online:
    items = soup.find_all("div", {"id": "is_online"})[0].decode_contents()
    if items:
        print(items)
        is_online = False
I also used:
items = soup.find_all("font")
for item in items:
    print(item.get_text())
but I couldn't find the online status again.
This is also the javascript code that generates the online status:
<script type="text/javascript">
var errtime = 0;
var ftime = 1;
var lastPair = '';
function subscribe(url) {
    var xhr = new XMLHttpRequest();
    if(ftime == 1)
        xhr.open('GET', '/script/table.php?ft=1', true);
    else
        xhr.open('GET', '/script/table.php', true);
    xhr.send();
    xhr.onreadystatechange = function()
    {
        if (xhr.readyState != 4) return;
        var isonline = document.getElementById('is_online');
        if (xhr.status != 200) {
            errtime += 1;
            if(errtime < 3)
            {
                setTimeout( subscribe('/script/table.php') , 30000);
            } else {
                // offline
                isonline.innerHTML = "<font color='red'><b>Offline</b>. Please refresh this page after few minutes</font>";
            }
        } else {
            // online
            isonline.innerHTML = "<font color='green'>online</font>";
            var result = JSON.parse(xhr.responseText);
            var stat24h = document.getElementById('stat24h');
            stat24h.innerHTML = result.stat;
            var table1 = result.table;
            var last1 = result.last;
            var tsumm = 0;
            for(var i=3;i<21;i++)
            {
                for(var j=1;j<14;j++)
                {
                    tsumm = 100*i + j;
                    var test = document.getElementById(i+"_"+j);
                    if(table1[tsumm] != null && test)
                    {
                        test.innerHTML = table1[tsumm];
                    } else {
                        if(test)
                            test.innerHTML = " ";
                    }
                }
            }
            errtime = 0;
            ftime = 2;
            subscribe('/script/table.php');
            if(lastPair != last1 && lastPair != "")
            {
                lastPair = last1;
                soundClick();
            } else {
                lastPair = last1;
            }
        }
    }
}
function soundClick() {
  var audio = new Audio();
  audio.src = '/libs/sounds/sound1.mp3';
  audio.autoplay = true;
}
</script>
Is there any solution in BeautifulSoup to be able to get the html element whenever the javascript generates it?
_ Thanks
 
     
    