H
H
haniaman2020-06-01 04:24:03
Parsing
haniaman, 2020-06-01 04:24:03

Python. How to display data that is constantly updated / supplemented?

Hello, but how to display data that is frequently updated. More precisely, on the site (rublix.best), there is a column "History of games" (prnt.sc/srdm2q). And how can I implement the output of data from this column not by restarting the script (which displays game data for the second when the script was launched) at different times, but by having the script immediately display them when new game data appears.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
ScriptKiddo, 2020-06-01
@haniaman

Are you trying to cheat the math? Well, not bad

from selenium import webdriver
from time import sleep

driver = webdriver.Chrome()

driver.get("https://rublix.best/")

prev_bet = 0
while True:

    all_bets = driver.find_elements_by_xpath("//div[contains(@class, 'history-line')]")
    if all_bets:
        last_bet = all_bets[0].text

        if last_bet != prev_bet:
            prev_bet = last_bet
            print(f'Last bet: {last_bet}')
    sleep(1)

A
Alexey Sundukov, 2020-06-01
@alekciy

If the end resource does not provide any API that implements notification during updates, then no way. Just a constant update.
In general, there is data there that is constantly loaded via AJAX, then you can open the page and not close it. And just constantly refer to it using the session ID.
There is another option when you can embed your own JS code into the page, which will track changes in the DOM of the page and send a notification to a given URL. But this is a rather difficult option.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question