Python Forum
How can i store a refreshing data - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How can i store a refreshing data (/thread-6642.html)



How can i store a refreshing data - Rius2 - Dec-01-2017

I am scraping the number of a counter from a website, my code will check the counter every 30 sec or so, what i want to do is check if the current value of the counter is greater than the last value then store the value as actual value and do something else just pass
I have no idea how to do this.


RE: How can i store a refreshing data - RickyWilson - Dec-01-2017

If your able to extract the value of the counter convert it to an int and keep checking it.

then = 0
while 1:
    now = int(check_timer())
    if now > then:
        then = now
        # do stuff now.
   



RE: How can i store a refreshing data - Rius2 - Dec-01-2017

Well that is so obvious, what troubled me is that i have a bigger code, and i wanted to create a def and call this counter_check def inside that code, but i was wondering how do i keep the now from keep setting itself up as then if i call it inside the _main_ that keeps looping, well the solution that you provided was simple, bring it outside the main loop Thank you.