import sys
import pymongo
import csv
import StockItem
import JsonItem
from urllib.request import urlopen
### Standard URI format: mongodb://[dbuser:dbpassword@]host:port/dbname

class Forcast(JsonItem.JsonItem):
    def __init__(self, symbol, current, high, highP, med, medP, low, lowP):
        self.symbol = symbol
        self.current = current
        self.high = high
        self.highP = highP
        self.med = med
        self.medP = medP
        self.low = low
        self.lowP = lowP

def get_url(name):
    return "https://markets.ft.com/data/equities/tearsheet/forecasts?s=%s:NSQ" % (name)

dburi = "mongodb://localhost:27017/"

def main(args):
    client = pymongo.MongoClient(dburi)
    db = client.get_database("nasdaq")
    stocks = db.stocks
    for idx, s in enumerate(stocks.find()):
        if idx < 5:
            print(s["Symbol"])

if __name__ == '__main__':
    main(sys.argv[1:])