import requests
import pandas as pd
import cv2
import time
mayor_api = 'https://api.hypixel.net/resources/skyblock/election'
bz_api = 'https://api.hypixel.net/skyblock/bazaar'
mayor_response = requests.get(mayor_api).json()
bz_response = requests.get(bz_api).json()
dict = bz_response.get('products')['COBBLESTONE']['quick_status']
df = pd.Series(pd.Series({'sellPrice':dict['sellPrice'], 'sellVolume':dict['sellVolume'], 'sellMovingWeek':dict['sellMovingWeek'], 'sellOrders':dict['sellOrders'], 'buyPrice':dict['buyPrice'], 'buyVolume':dict['buyVolume'], 'buyMovingWeek':dict['buyMovingWeek'], 'buyOrders':dict['buyOrders']}))
df = pd.DataFrame()
while(True):
    bz_response = requests.get(bz_api).json()
    dict = bz_response.get('products')['COBBLESTONE']['quick_status']
    new = pd.DataFrame({'sellPrice':dict['sellPrice'], 'sellVolume':dict['sellVolume'], 'sellMovingWeek':dict['sellMovingWeek'], 'sellOrders':dict['sellOrders'], 'buyPrice':dict['buyPrice'], 'buyVolume':dict['buyVolume'], 'buyMovingWeek':dict['buyMovingWeek'], 'buyOrders':dict['buyOrders']}, index=[1])
    df = pd.concat([df, new])
    df.to_csv('cobblestone_price.csv')
    cv2.waitKey(5000)
    time.sleep(5)
