Here is yet another problem I am over thinking. I want the code to only print when the time that I scrape changes. All it does now is just keep printing the current price and never changes. What am I doing wrong?
import urllib.request
import bs4 as bs
while True:
# Request Webpage
url =
urllib.request.urlopen('https://markets.businessinsider.com/index/realtime-chart/dow_jones').read()
# Raw Webpage
rawpage = bs.BeautifulSoup(url, 'lxml')
price = rawpage.find_all('span', class_='push-data')[0]
change = rawpage.find_all('span', class_='push-data')[1]
currenttime = rawpage.find_all('span', class_='push-data')[3]
new_time = ""
if new_time != currenttime:
print(price.text)
print(change.text)
print(currenttime.text)
Aucun commentaire:
Enregistrer un commentaire