[英]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.我试图设置无限循环以每 5 秒获取一次最新货币并在我的终端中显示该货币,但由于某种原因,我只看到当前货币一次,仅此而已。
Could you guys please tell me how to improve my code to see the current currency every 5 seconds?你们能否告诉我如何改进我的代码以每 5 秒查看一次当前货币?
PS The programm keeps working without any errors: Here's what I see: PS该程序继续运行而没有任何错误:这是我所看到的:
/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非常感谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.