Infinite loop Python Threading

Question:

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:

/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

Asked By: iprahka

||

Answers:

Perhaps you should not use return it stops the function

More info

Answered By: TheTS
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.