I have the code below, the code below will take the value from the pluang.com site, but I want to make 2 colors so that I don't get confused and it's easy to understand.
I want if the scraped value is below (-) 860,000 (mis. 850.000) then the print must be red, if it is above (+) 860,000 (mis. 870.000) then the print must be green.
Can anyone help? Thank you.
from urllib.request import urlopen, Request
from bs4 import BeautifulSoup
from datetime import datetime
import time
import os
class bcolors:
SELL = '\033[92m'
BUY = '\033[31;1m'
os.system("clear")
while True:
url = "https://pluang.com/produk/pluang-emas"
UserAgent = Request(url, headers={'User-Agent':'Mozilla/5.0'})
html = urlopen(UserAgent)
data = BeautifulSoup(html, "html.parser")
items = data.findAll("h1", {"id":"gold-price"})
for item in items:
print(bcolors.BUY + " SELL GOLD:",item.get_text().strip(),"-",datetime.now())
time.sleep(59)