Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Infinite loop Python Threading

Im trying to set up the infinite loop to get the latest currency every 5 seconds and to show up that currency in my terminal but for some reason I see the current currency just once and that’s it.

Could you guys please tell me how to improve my code to see the current currency every 5 seconds?

P.S. The programm keeps working without any errors: Here’s what I see:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

/Users/iprahka/PycharmProjects/Test2/main.py:6: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
  driver = webdriver.Chrome(executable_path='/Applications/Python 3.10/chromedriver')
[<div class="subPrice">₽1,511,937.64</div>]```


And here’s my code:

from threading import Thread
from bs4 import BeautifulSoup
import time
from selenium import webdriver

driver = webdriver.Chrome(executable_path='/Applications/Python 3.10/chromedriver')
def runA():
    while True:

        url = 'https://www.binance.com/trade/BTC_USDT?theme=dark&type=spot'
        driver.get(url)
        time.sleep(5)
        response = driver.page_source
        soup = BeautifulSoup(response, 'html.parser')
        convert = soup.findAll('div', {'class': 'subPrice'})
        print(convert)
        return convert[0].text

if __name__ == "__main__":
    t1 = Thread(target = runA)
    t1.daemon
    t1.start()
    while True:
        pass

Thanks a lot

>Solution :

Perhaps you should not use return it stops the function

More info

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading