__author__ = 'SeanSmith'


from pprint import pprint
import requests, json
import selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
from matplotlib import pyplot as plt
import datetime


#Format
#{"importance": 0-10, "sentiment": positive/negative/neutral, "score":0-1}
#

def get_sentiment(text):
    r = requests.get("https://api.idolondemand.com/1/api/sync/analyzesentiment/v1?apikey=fe6dea49-084f-4cd8-be86-0976baf9a714&text="+str(text))

    if(r.status_code == 200):
        #print(r.text)
        data2 = json.loads(r.text)
        #pprint(data2)

        return data2['aggregate']['score']
    else:
        print("Error return code = "+r.status_code)




def get_text(url):
    dlst = []
    driver = webdriver.Firefox()
    driver.get(url)
    the_table = driver.find_element_by_id("siteTable")
    elements = the_table.find_elements_by_tag_name("div")
    print(elements)
    for element in elements:
        if(len(element.find_elements_by_class_name("title"))>0):
            text = element.find_element_by_class_name("title").text
            print(text)
            dlst += [text]

    driver.quit()
    return dlst



#counter= 0

#text = get_text("http://www.reddit.com/r/Bitcoin/")
#print(text)
#for each in text:
    #counter += get_sentiment(each)

#print(counter)


def graph(x_series, y_series, x_series1, y_series1, color1, color2):
    plt.figure( 1 )
    plt.plot(x_series, y_series, color1)
    plt.plot(x_series1, y_series1, color2)
    plt.draw()
    plt.show()


def get_graph_data(filename):
    file = open(filename, 'r').read()
    file = eval(file)



    x = []
    y = []
    for each in file:

        x += [each[0]*10000+each[1]*100+each[2]]
        y += [file[each]]


    if(filename == 'bitcoinprices.txt'):
        x = [20130403, 20120711, 20120617, 20121202, 20110325, 20140830, 20110910, 20101201, 20130131, 20131212, 20120207, 20110715, 20110421, 20111120, 20101129, 20130806, 20130918, 20121010, 20111226, 20140701, 20120608, 20120516, 20121225, 20120106, 20110414, 20110518, 20110821, 20140328, 20101026, 20130905, 20131019, 20120911, 20111203, 20140606, 20100920, 20130601, 20120509, 20110123, 20140508, 20130325, 20110509, 20110219, 20140910, 20140203, 20131004, 20131120, 20120329, 20120812, 20111028, 20140107, 20100913, 20100823, 20130714, 20120406, 20121130, 20140517, 20140411, 20130424, 20110208, 20110316, 20140809, 20110901, 20101224, 20130122, 20131103, 20131221, 20110706, 20111005, 20100814, 20101122, 20130815, 20121107, 20121029, 20140418, 20140710, 20130527, 20120603, 20121216, 20110311, 20110924, 20130109, 20130223, 20131202, 20120131, 20110407, 20111106, 20110830, 20140305, 20101115, 20101017, 20100722, 20130912, 20121004, 20120928, 20111220, 20140719, 20140613, 20130626, 20120502, 20110130, 20130208, 20130316, 20140903, 20110807, 20140226, 20101008, 20131013, 20120318, 20120905, 20120827, 20110626, 20140620, 20140112, 20100902, 20130721, 20120413, 20110105, 20140506, 20130315, 20130417, 20120725, 20110201, 20140924, 20101219, 20131110, 20120311, 20120217, 20120802, 20110725, 20111018, 20140121, 20100801, 20130820, 20121112, 20140405, 20130414, 20130518, 20120626, 20121207, 20110302, 20140827, 20110915, 20101210, 20131211, 20120208, 20120116, 20110424, 20111117, 20140314, 20100731, 20130923, 20121015, 20111229, 20140704, 20130513, 20130619, 20120527, 20121230, 20130201, 20120109, 20110816, 20140323, 20140217, 20101007, 20131022, 20120914, 20111206, 20140603, 20100927, 20130612, 20130728, 20120420, 20110112, 20140515, 20130306, 20120722, 20140917, 20140208, 20131117, 20120809, 20110716, 20111027, 20140102, 20100824, 20130703, 20130829, 20121121, 20140520, 20140412, 20130407, 20120715, 20120621, 20110329, 20140818, 20110906, 20101205, 20130127, 20131216, 20120203, 20110711, 20110417, 20111124, 20101125, 20130802, 20130930, 20121022, 20140423, 20140713, 20130504, 20120612, 20120520, 20121221, 20110929, 20130226, 20120102, 20110410, 20110522, 20111103, 20110825, 20101030, 20100717, 20130901, 20131031, 20120923, 20111215, 20140722, 20140610, 20100916, 20130605, 20120513, 20120427, 20110119, 20130329, 20110513, 20110223, 20140914, 20110802, 20131124, 20120325, 20120816, 20140617, 20140111, 20100909, 20100819, 20130710, 20120402, 20121126, 20140529, 20130428, 20120704, 20110212, 20110320, 20140813, 20101228, 20130118, 20131107, 20131225, 20120314, 20120226, 20110702, 20111009, 20140116, 20100810, 20101118, 20130811, 20121103, 20121025, 20140430, 20130531, 20120607, 20121212, 20110315, 20110920, 20130105, 20130219, 20131206, 20120213, 20120127, 20110403, 20111110, 20140309, 20101111, 20101021, 20100726, 20130908, 20120924, 20111216, 20140731, 20130630, 20120506, 20110126, 20141003, 20130204, 20130320, 20120112, 20110504, 20140907, 20110811, 20140318, 20140222, 20101012, 20131009, 20120901, 20120831, 20140624, 20100930, 20130717, 20120409, 20110101, 20140502, 20130303, 20130421, 20120729, 20110205, 20140928, 20140804, 20140213, 20101223, 20131114, 20120307, 20120806, 20110721, 20111022, 20140125, 20100829, 20130816, 20121108, 20140401, 20130402, 20130522, 20120710, 20120630, 20121203, 20110306, 20140831, 20110911, 20101214, 20130128, 20131215, 20120204, 20110712, 20110420, 20111121, 20101128, 20130919, 20121011, 20111225, 20130501, 20130623, 20120609, 20120531, 20121226, 20120105, 20110413, 20110519, 20110820, 20140327, 20101027, 20131018, 20120910, 20111202, 20140607, 20100923, 20130724, 20120508, 20120416, 20110108, 20140511, 20130326, 20110510, 20110218, 20140921, 20140204, 20131121, 20120328, 20120813, 20111031, 20140106, 20100912, 20100820, 20130715, 20130825, 20120407, 20121117, 20140516, 20140408, 20130427, 20120703, 20110211, 20110317, 20140822, 20110902, 20101225, 20130123, 20131220, 20110707, 20111004, 20111128, 20100815, 20101121, 20130814, 20130926, 20121106, 20121018, 20140419, 20140709, 20130524, 20121217, 20110308, 20110925, 20130114, 20130222, 20120130, 20110406, 20111107, 20110829, 20140304, 20101114, 20101018, 20100721, 20130913, 20131027, 20121005, 20120919, 20111211, 20140718, 20140614, 20130625, 20120501, 20110131, 20130215, 20130317, 20110501, 20140902, 20110806, 20140227, 20101009, 20131012, 20131128, 20120321, 20120904, 20120820, 20110629, 20140621, 20140115, 20100905, 20130722, 20120414, 20110106, 20140525, 20130308, 20130416, 20120724, 20140927, 20140801, 20101216, 20131111, 20131229, 20120310, 20120222, 20120803, 20110730, 20111013, 20140120, 20100806, 20130823, 20121115, 20140426, 20130409, 20130519, 20120627, 20121208, 20110303, 20140824, 20110916, 20101211, 20130101, 20131210, 20120209, 20120123, 20111114, 20140313, 20101107, 20100730, 20130920, 20121012, 20111228, 20140727, 20130510, 20130618, 20120526, 20121231, 20120108, 20110815, 20140322, 20140218, 20131021, 20120913, 20111205, 20140628, 20100926, 20130611, 20130729, 20120421, 20110113, 20140514, 20130307, 20120717, 20110225, 20140916, 20140209, 20131118, 20120303, 20120810, 20110717, 20111026, 20140129, 20100825, 20130704, 20130828, 20121120, 20140523, 20140413, 20130406, 20120714, 20120618, 20110326, 20140819, 20110907, 20101202, 20130124, 20131219, 20110708, 20110416, 20111003, 20111125, 20101124, 20130805, 20121023, 20140420, 20140712, 20130505, 20120613, 20120519, 20121222, 20110930, 20130225, 20120101, 20110409, 20110824, 20140331, 20101031, 20130906, 20131030, 20120922, 20111214, 20140721, 20140611, 20100919, 20130604, 20120512, 20120428, 20110120, 20130330, 20110514, 20110222, 20140909, 20110801, 20131007, 20131125, 20120324, 20120817, 20140618, 20140110, 20100908, 20100816, 20130711, 20120403, 20121129, 20140528, 20120707, 20110215, 20110321, 20140810, 20101229, 20130119, 20131224, 20120227, 20110703, 20111008, 20140119, 20100811, 20101117, 20130810, 20121102, 20121030, 20130528, 20120604, 20121213, 20110312, 20110921, 20130110, 20130218, 20131201, 20120126, 20110402, 20111111, 20140308, 20101110, 20101022, 20100725, 20130909, 20121001, 20111223, 20140730, 20130629, 20120505, 20110127, 20141004, 20130211, 20130321, 20110505, 20140906, 20110810, 20140317, 20140223, 20101013, 20131008, 20120317, 20120824, 20140625, 20100901, 20130718, 20120410, 20110102, 20140505, 20130312, 20130420, 20120728, 20110204, 20140805, 20140214, 20101220, 20131115, 20120306, 20120218, 20120807, 20110726, 20111017, 20140124, 20100802, 20130819, 20121111, 20140406, 20130413, 20130523, 20121204, 20110307, 20140828, 20110912, 20101215, 20130129, 20131214, 20120205, 20120119, 20110713, 20110427, 20111118, 20101103, 20130916, 20121008, 20111224, 20140707, 20130514, 20130622, 20120530, 20121227, 20130228, 20120104, 20110412, 20110819, 20140326, 20101004, 20131017, 20120909, 20111201, 20100922, 20130615, 20130725, 20120417, 20110109, 20140510, 20130327, 20120721, 20110511, 20140920, 20140205, 20131122, 20120331, 20120814, 20111030, 20140101, 20100915, 20100821, 20130824, 20121116, 20140519, 20140409, 20130426, 20120702, 20120622, 20110210, 20110330, 20140823, 20110903, 20101206, 20130120, 20131223, 20120228, 20110704, 20111007, 20111129, 20100812, 20101120, 20130801, 20130927, 20121019, 20140416, 20140708, 20130525, 20120601, 20120523, 20121218, 20110309, 20110926, 20130115, 20130221, 20120129, 20110405, 20111104, 20110828, 20140303, 20101113, 20101019, 20100720, 20130902, 20131026, 20120918, 20111210, 20140717, 20140615, 20130624, 20120424, 20110116, 20130214, 20130318, 20110502, 20140913, 20110805, 20140228, 20101010, 20131003, 20131129, 20120320, 20120821, 20110628, 20140622, 20140114, 20100904, 20130723, 20120415, 20121125, 20110107, 20140524, 20130309, 20130419, 20120727, 20110203, 20140926, 20140814, 20101217, 20131104, 20131228, 20120313, 20120223, 20110731, 20111012, 20140123, 20100807, 20130822, 20121114, 20121026, 20140427, 20130408, 20130516, 20120624, 20121209, 20140825, 20110917, 20101208, 20130106, 20131205, 20120214, 20120122, 20110430, 20111115, 20140312, 20101106, 20100729, 20130921, 20121013, 20120927, 20111219, 20140726, 20130511, 20130617, 20120525, 20130207, 20120115, 20110814, 20140321, 20140219, 20101001, 20131020, 20120912, 20120828, 20111204, 20140629, 20100929, 20130610, 20130730, 20120422, 20110114, 20140501, 20120716, 20110224, 20140919, 20140210, 20131119, 20120302, 20120811, 20110722, 20111021, 20140128, 20100830, 20130705, 20130831, 20121123, 20140522, 20140402, 20130401, 20120709, 20120619, 20110327, 20140816, 20110908, 20101203, 20130125, 20131218, 20120201, 20110709, 20110423, 20111002, 20111122, 20130804, 20130928, 20121020, 20140421, 20140703, 20130502, 20120610, 20120518, 20121223, 20130224, 20110408, 20110516, 20111101, 20110823, 20140330, 20101024, 20130907, 20131029, 20120921, 20111213, 20140720, 20140604, 20100918, 20130603, 20120511, 20120429, 20110121, 20130331, 20110515, 20110217, 20140908, 20140201, 20131006, 20131126, 20120327, 20120818, 20140619, 20140105, 20100911, 20100817, 20130712, 20120404, 20121128, 20140531, 20130430, 20120706, 20110214, 20110318, 20140811, 20101226, 20130116, 20131101, 20131227, 20120224, 20111011, 20140118, 20100808, 20101116, 20130813, 20121105, 20121031, 20140428, 20130529, 20120605, 20121214, 20110313, 20110922, 20130111, 20130217, 20120125, 20110401, 20111108, 20140307, 20101109, 20101023, 20100724, 20130914, 20121006, 20120930, 20111222, 20140729, 20130628, 20120504, 20110128, 20130210, 20130322, 20110506, 20140901, 20110809, 20140316, 20140224, 20101014, 20131015, 20120316, 20120907, 20120825, 20140626, 20130719, 20120411, 20110103, 20140504, 20130313, 20130423, 20120731, 20110207, 20140930, 20140802, 20140215, 20101221, 20131108, 20120309, 20120219, 20110727, 20111016, 20140127, 20100803, 20130818, 20121110, 20140407, 20130412, 20130520, 20120628, 20121205, 20110304, 20140829, 20110913, 20101212, 20130102, 20131209, 20120210, 20120118, 20110426, 20111119, 20101102, 20130917, 20121009, 20111231, 20140706, 20130515, 20130621, 20120529, 20121228, 20130203, 20120111, 20110818, 20140325, 20101005, 20131016, 20120908, 20140601, 20100925, 20130614, 20130726, 20120418, 20110110, 20140513, 20130304, 20120720, 20110228, 20140923, 20140206, 20131123, 20120330, 20120815, 20110718, 20111025, 20100914, 20100826, 20130701, 20130827, 20121119, 20140518, 20140414, 20130405, 20120713, 20120623, 20110331, 20140820, 20110904, 20101207, 20130121, 20131222, 20110705, 20110419, 20111006, 20111126, 20100813, 20101127, 20130924, 20121016, 20140417, 20140715, 20130506, 20120614, 20120522, 20121219, 20110927, 20130112, 20130220, 20120128, 20110404, 20110520, 20111105, 20110827, 20140302, 20101112, 20101028, 20100719, 20130903, 20131025, 20120917, 20111209, 20140716, 20140608, 20130607, 20120515, 20120425, 20110117, 20130213, 20130319, 20110503, 20110221, 20140912, 20110804, 20101011, 20131002, 20131130, 20120323, 20120822, 20140623, 20140109, 20100907, 20130708, 20121124, 20140527, 20130310, 20130418, 20120726, 20110202, 20110322, 20140815, 20101230, 20131105, 20131231, 20120312, 20120220, 20110728, 20111015, 20140122, 20100804, 20130809, 20121101, 20121027, 20140424, 20130411, 20130517, 20120625, 20121210, 20110301, 20110918, 20101209, 20130107, 20131204, 20120215, 20120121, 20110429, 20111112, 20140311, 20101105, 20100728, 20130910, 20121002, 20120926, 20111218, 20140725, 20130508, 20130616, 20120524, 20110124, 20141001, 20130206, 20120114, 20140905, 20110813, 20140320, 20140220, 20101002, 20131011, 20120903, 20120829, 20140630, 20100928, 20130609, 20130731, 20120423, 20110115, 20130301, 20120719, 20110227, 20140918, 20140806, 20140211, 20131112, 20120305, 20120804, 20110723, 20111020, 20140131, 20100831, 20130706, 20130830, 20121122, 20140403, 20120708, 20120616, 20121201, 20110324, 20140817, 20110909, 20130130, 20131213, 20120206, 20110714, 20110422, 20111123, 20101130, 20130807, 20130929, 20121021, 20111227, 20140702, 20130503, 20120611, 20120517, 20121224, 20120107, 20110415, 20110517, 20110822, 20140329, 20101025, 20130904, 20131028, 20120920, 20111212, 20140605, 20100921, 20130602, 20120510, 20120430, 20110122, 20140509, 20130324, 20110508, 20110216, 20140911, 20140202, 20131005, 20131127, 20120326, 20120819, 20111029, 20140104, 20100910, 20100822, 20130713, 20120405, 20140530, 20140410, 20130425, 20120701, 20110209, 20110319, 20140808, 20101227, 20130117, 20131102, 20131226, 20120225, 20110701, 20111010, 20111130, 20100809, 20101123, 20130812, 20121104, 20121028, 20140429, 20140711, 20130526, 20120602, 20121215, 20110310, 20110923, 20130108, 20130216, 20131203, 20120124, 20111109, 20110831, 20140306, 20101108, 20101016, 20100723, 20130915, 20121007, 20120929, 20111221, 20140728, 20140612, 20130627, 20120503, 20110129, 20130209, 20130323, 20110507, 20110808, 20140225, 20101015, 20131014, 20120319, 20120906, 20120826, 20110627, 20140627, 20140113, 20100903, 20130720, 20120412, 20110104, 20140507, 20130314, 20130422, 20120730, 20110206, 20140925, 20140803, 20101218, 20131109, 20120308, 20120216, 20120801, 20110724, 20111019, 20140126, 20130821, 20121113, 20140404, 20130415, 20130521, 20120629, 20121206, 20110305, 20140826, 20110914, 20101213, 20130103, 20131208, 20120211, 20120117, 20110425, 20111116, 20140315, 20101101, 20130922, 20121014, 20111230, 20140705, 20130512, 20130620, 20120528, 20121229, 20130202, 20120110, 20110817, 20140324, 20140216, 20101006, 20131023, 20120915, 20111207, 20140602, 20100924, 20130613, 20130727, 20120419, 20110111, 20140512, 20130305, 20120723, 20140922, 20140207, 20131116, 20120301, 20120808, 20110719, 20111024, 20140103, 20100827, 20130702, 20130826, 20121118, 20140521, 20140415, 20130404, 20120712, 20120620, 20110328, 20140821, 20110905, 20101204, 20130126, 20131217, 20120202, 20110710, 20110418, 20111001, 20111127, 20101126, 20130803, 20130925, 20121017, 20140422, 20140714, 20130507, 20120615, 20120521, 20121220, 20110928, 20130113, 20130227, 20120103, 20110411, 20110521, 20111102, 20110826, 20140301, 20101029, 20100718, 20131024, 20120916, 20111208, 20140723, 20140609, 20100917, 20130606, 20120514, 20120426, 20110118, 20130212, 20130328, 20110512, 20110220, 20140915, 20110803, 20131001, 20120322, 20120823, 20110630, 20140616, 20140108, 20100906, 20100818, 20130709, 20120401, 20121127, 20140526, 20130311, 20130429, 20120705, 20110213, 20110323, 20140812, 20101231, 20131106, 20131230, 20120315, 20120221, 20110729, 20111014, 20140117, 20100805, 20101119, 20130808, 20121024, 20140425, 20130410, 20130530, 20120606, 20121211, 20110314, 20110919, 20130104, 20131207, 20120212, 20120120, 20110428, 20111113, 20140310, 20101104, 20101020, 20100727, 20130911, 20121003, 20120925, 20111217, 20140724, 20130509, 20120507, 20110125, 20141002, 20130205, 20120113, 20140904, 20110812, 20140319, 20140221, 20101003, 20131010, 20120902, 20120830, 20130608, 20130716, 20120408, 20140503, 20130302, 20120718, 20110226, 20140929, 20140807, 20140212, 20101222, 20131113, 20120304, 20120805, 20110720, 20111023, 20140130, 20100828, 20130707, 20130817, 20121109]
    else:
        x = [20131019, 20130109, 20130315, 20130513, 20130306, 20130703, 20130127, 20130504, 20130901, 20130329, 20130710, 20130118, 20130531, 20130908, 20130320, 20130717, 20130522, 20130919, 20130724, 20130926, 20130215, 20130409, 20130611, 20130406, 20130805, 20130225, 20130604, 20131007, 20130810, 20130218, 20130629, 20131008, 20130420, 20130819, 20130622, 20131017, 20130824, 20130115, 20131026, 20130309, 20130106, 20130511, 20130705, 20130125, 20130502, 20130907, 20130331, 20130712, 20130116, 20130529, 20130914, 20130322, 20130719, 20130520, 20130917, 20130726, 20130924, 20130213, 20130411, 20130206, 20130609, 20130807, 20130602, 20131005, 20130425, 20130812, 20130216, 20130627, 20131014, 20130422, 20130821, 20130620, 20131023, 20130826, 20130113, 20131024, 20130311, 20130104, 20130509, 20130302, 20130707, 20130131, 20130905, 20130325, 20130714, 20130122, 20130527, 20130912, 20130316, 20130721, 20130518, 20130923, 20130728, 20130930, 20130204, 20130402, 20130427, 20130814, 20130222, 20130625, 20131012, 20130416, 20130823, 20130618, 20131021, 20130828, 20131030, 20130110, 20130312, 20130129, 20130514, 20130327, 20130120, 20130525, 20130902, 20130318, 20130723, 20130516, 20130921, 20130730, 20130928, 20130210, 20130412, 20130203, 20130614, 20130405, 20130220, 20130607, 20131002, 20130418, 20130809, 20130616, 20131011, 20130830, 20131028, 20130108, 20130314, 20130103, 20130512, 20130305, 20130702, 20130126, 20130507, 20130328, 20130709, 20130530, 20130911, 20130716, 20130918, 20130208, 20130414, 20130201, 20130612, 20130407, 20130802, 20130226, 20130605, 20130428, 20130811, 20130219, 20130630, 20131009, 20130421, 20130816, 20130623, 20131018, 20130825, 20130114, 20131027, 20130308, 20130101, 20130510, 20130307, 20130704, 20130124, 20130505, 20130906, 20130330, 20130711, 20130119, 20130528, 20130909, 20130321, 20130718, 20130523, 20130916, 20130725, 20130927, 20130214, 20130408, 20130207, 20130610, 20130401, 20130804, 20130224, 20130603, 20131006, 20130430, 20130813, 20130217, 20130628, 20131015, 20130423, 20130818, 20130621, 20131016, 20130827, 20130112, 20131025, 20130310, 20130107, 20130508, 20130301, 20130706, 20130130, 20130503, 20130904, 20130324, 20130713, 20130117, 20130526, 20130915, 20130323, 20130720, 20130521, 20130922, 20130727, 20130925, 20130212, 20130410, 20130205, 20130608, 20130403, 20130806, 20130601, 20131004, 20130424, 20130815, 20130223, 20130626, 20131013, 20130417, 20130820, 20130619, 20131022, 20130829, 20130105, 20130303, 20130128, 20130501, 20130326, 20130715, 20130123, 20130524, 20130913, 20130317, 20130722, 20130519, 20130920, 20130729, 20130211, 20130413, 20130228, 20130615, 20130426, 20130801, 20130221, 20130624, 20131003, 20130419, 20130822, 20130617, 20131020, 20130831, 20131029, 20130111, 20130313, 20130102, 20130515, 20130304, 20130701, 20130121, 20130506, 20130903, 20130319, 20130708, 20130517, 20130910, 20130731, 20130929, 20130209, 20130415, 20130202, 20130613, 20130404, 20130803, 20130227, 20130606, 20131001, 20130429, 20130808, 20131010, 20130817]



    x = sorted(x)


    prices = []
    dates = []

    for each in x:

        date = str(each)
        year = int(date[0:4])
        month = int(date[4:6])
        day = int(date[6:8])
        tuple = (year, month, day)
        print(each)
        prices += [file[tuple]]
        dates += [float(each)]

    print(dates)
    print(prices)
    return dates, prices




dates, prices = get_graph_data('bitcoinprices.txt')

date, sentiment = get_graph_data('sentiment.txt')

print(date, sentiment)
graph([], [], date, sentiment,  "r", "b")



fd9b1c962e063a710dd6384a15bb9466661ba5a7
<mask token>


def get_sentiment(text):
    r = requests.get(
        'https://api.idolondemand.com/1/api/sync/analyzesentiment/v1?apikey=fe6dea49-084f-4cd8-be86-0976baf9a714&text='
         + str(text))
    if r.status_code == 200:
        data2 = json.loads(r.text)
        return data2['aggregate']['score']
    else:
        print('Error return code = ' + r.status_code)


def get_text(url):
    dlst = []
    driver = webdriver.Firefox()
    driver.get(url)
    the_table = driver.find_element_by_id('siteTable')
    elements = the_table.find_elements_by_tag_name('div')
    print(elements)
    for element in elements:
        if len(element.find_elements_by_class_name('title')) > 0:
            text = element.find_element_by_class_name('title').text
            print(text)
            dlst += [text]
    driver.quit()
    return dlst


<mask token>


def get_graph_data(filename):
    file = open(filename, 'r').read()
    file = eval(file)
    x = []
    y = []
    for each in file:
        x += [each[0] * 10000 + each[1] * 100 + each[2]]
        y += [file[each]]
    if filename == 'bitcoinprices.txt':
        x = [20130403, 20120711, 20120617, 20121202, 20110325, 20140830, 
            20110910, 20101201, 20130131, 20131212, 20120207, 20110715, 
            20110421, 20111120, 20101129, 20130806, 20130918, 20121010, 
            20111226, 20140701, 20120608, 20120516, 20121225, 20120106, 
            20110414, 20110518, 20110821, 20140328, 20101026, 20130905, 
            20131019, 20120911, 20111203, 20140606, 20100920, 20130601, 
            20120509, 20110123, 20140508, 20130325, 20110509, 20110219, 
            20140910, 20140203, 20131004, 20131120, 20120329, 20120812, 
            20111028, 20140107, 20100913, 20100823, 20130714, 20120406, 
            20121130, 20140517, 20140411, 20130424, 20110208, 20110316, 
            20140809, 20110901, 20101224, 20130122, 20131103, 20131221, 
            20110706, 20111005, 20100814, 20101122, 20130815, 20121107, 
            20121029, 20140418, 20140710, 20130527, 20120603, 20121216, 
            20110311, 20110924, 20130109, 20130223, 20131202, 20120131, 
            20110407, 20111106, 20110830, 20140305, 20101115, 20101017, 
            20100722, 20130912, 20121004, 20120928, 20111220, 20140719, 
            20140613, 20130626, 20120502, 20110130, 20130208, 20130316, 
            20140903, 20110807, 20140226, 20101008, 20131013, 20120318, 
            20120905, 20120827, 20110626, 20140620, 20140112, 20100902, 
            20130721, 20120413, 20110105, 20140506, 20130315, 20130417, 
            20120725, 20110201, 20140924, 20101219, 20131110, 20120311, 
            20120217, 20120802, 20110725, 20111018, 20140121, 20100801, 
            20130820, 20121112, 20140405, 20130414, 20130518, 20120626, 
            20121207, 20110302, 20140827, 20110915, 20101210, 20131211, 
            20120208, 20120116, 20110424, 20111117, 20140314, 20100731, 
            20130923, 20121015, 20111229, 20140704, 20130513, 20130619, 
            20120527, 20121230, 20130201, 20120109, 20110816, 20140323, 
            20140217, 20101007, 20131022, 20120914, 20111206, 20140603, 
            20100927, 20130612, 20130728, 20120420, 20110112, 20140515, 
            20130306, 20120722, 20140917, 20140208, 20131117, 20120809, 
            20110716, 20111027, 20140102, 20100824, 20130703, 20130829, 
            20121121, 20140520, 20140412, 20130407, 20120715, 20120621, 
            20110329, 20140818, 20110906, 20101205, 20130127, 20131216, 
            20120203, 20110711, 20110417, 20111124, 20101125, 20130802, 
            20130930, 20121022, 20140423, 20140713, 20130504, 20120612, 
            20120520, 20121221, 20110929, 20130226, 20120102, 20110410, 
            20110522, 20111103, 20110825, 20101030, 20100717, 20130901, 
            20131031, 20120923, 20111215, 20140722, 20140610, 20100916, 
            20130605, 20120513, 20120427, 20110119, 20130329, 20110513, 
            20110223, 20140914, 20110802, 20131124, 20120325, 20120816, 
            20140617, 20140111, 20100909, 20100819, 20130710, 20120402, 
            20121126, 20140529, 20130428, 20120704, 20110212, 20110320, 
            20140813, 20101228, 20130118, 20131107, 20131225, 20120314, 
            20120226, 20110702, 20111009, 20140116, 20100810, 20101118, 
            20130811, 20121103, 20121025, 20140430, 20130531, 20120607, 
            20121212, 20110315, 20110920, 20130105, 20130219, 20131206, 
            20120213, 20120127, 20110403, 20111110, 20140309, 20101111, 
            20101021, 20100726, 20130908, 20120924, 20111216, 20140731, 
            20130630, 20120506, 20110126, 20141003, 20130204, 20130320, 
            20120112, 20110504, 20140907, 20110811, 20140318, 20140222, 
            20101012, 20131009, 20120901, 20120831, 20140624, 20100930, 
            20130717, 20120409, 20110101, 20140502, 20130303, 20130421, 
            20120729, 20110205, 20140928, 20140804, 20140213, 20101223, 
            20131114, 20120307, 20120806, 20110721, 20111022, 20140125, 
            20100829, 20130816, 20121108, 20140401, 20130402, 20130522, 
            20120710, 20120630, 20121203, 20110306, 20140831, 20110911, 
            20101214, 20130128, 20131215, 20120204, 20110712, 20110420, 
            20111121, 20101128, 20130919, 20121011, 20111225, 20130501, 
            20130623, 20120609, 20120531, 20121226, 20120105, 20110413, 
            20110519, 20110820, 20140327, 20101027, 20131018, 20120910, 
            20111202, 20140607, 20100923, 20130724, 20120508, 20120416, 
            20110108, 20140511, 20130326, 20110510, 20110218, 20140921, 
            20140204, 20131121, 20120328, 20120813, 20111031, 20140106, 
            20100912, 20100820, 20130715, 20130825, 20120407, 20121117, 
            20140516, 20140408, 20130427, 20120703, 20110211, 20110317, 
            20140822, 20110902, 20101225, 20130123, 20131220, 20110707, 
            20111004, 20111128, 20100815, 20101121, 20130814, 20130926, 
            20121106, 20121018, 20140419, 20140709, 20130524, 20121217, 
            20110308, 20110925, 20130114, 20130222, 20120130, 20110406, 
            20111107, 20110829, 20140304, 20101114, 20101018, 20100721, 
            20130913, 20131027, 20121005, 20120919, 20111211, 20140718, 
            20140614, 20130625, 20120501, 20110131, 20130215, 20130317, 
            20110501, 20140902, 20110806, 20140227, 20101009, 20131012, 
            20131128, 20120321, 20120904, 20120820, 20110629, 20140621, 
            20140115, 20100905, 20130722, 20120414, 20110106, 20140525, 
            20130308, 20130416, 20120724, 20140927, 20140801, 20101216, 
            20131111, 20131229, 20120310, 20120222, 20120803, 20110730, 
            20111013, 20140120, 20100806, 20130823, 20121115, 20140426, 
            20130409, 20130519, 20120627, 20121208, 20110303, 20140824, 
            20110916, 20101211, 20130101, 20131210, 20120209, 20120123, 
            20111114, 20140313, 20101107, 20100730, 20130920, 20121012, 
            20111228, 20140727, 20130510, 20130618, 20120526, 20121231, 
            20120108, 20110815, 20140322, 20140218, 20131021, 20120913, 
            20111205, 20140628, 20100926, 20130611, 20130729, 20120421, 
            20110113, 20140514, 20130307, 20120717, 20110225, 20140916, 
            20140209, 20131118, 20120303, 20120810, 20110717, 20111026, 
            20140129, 20100825, 20130704, 20130828, 20121120, 20140523, 
            20140413, 20130406, 20120714, 20120618, 20110326, 20140819, 
            20110907, 20101202, 20130124, 20131219, 20110708, 20110416, 
            20111003, 20111125, 20101124, 20130805, 20121023, 20140420, 
            20140712, 20130505, 20120613, 20120519, 20121222, 20110930, 
            20130225, 20120101, 20110409, 20110824, 20140331, 20101031, 
            20130906, 20131030, 20120922, 20111214, 20140721, 20140611, 
            20100919, 20130604, 20120512, 20120428, 20110120, 20130330, 
            20110514, 20110222, 20140909, 20110801, 20131007, 20131125, 
            20120324, 20120817, 20140618, 20140110, 20100908, 20100816, 
            20130711, 20120403, 20121129, 20140528, 20120707, 20110215, 
            20110321, 20140810, 20101229, 20130119, 20131224, 20120227, 
            20110703, 20111008, 20140119, 20100811, 20101117, 20130810, 
            20121102, 20121030, 20130528, 20120604, 20121213, 20110312, 
            20110921, 20130110, 20130218, 20131201, 20120126, 20110402, 
            20111111, 20140308, 20101110, 20101022, 20100725, 20130909, 
            20121001, 20111223, 20140730, 20130629, 20120505, 20110127, 
            20141004, 20130211, 20130321, 20110505, 20140906, 20110810, 
            20140317, 20140223, 20101013, 20131008, 20120317, 20120824, 
            20140625, 20100901, 20130718, 20120410, 20110102, 20140505, 
            20130312, 20130420, 20120728, 20110204, 20140805, 20140214, 
            20101220, 20131115, 20120306, 20120218, 20120807, 20110726, 
            20111017, 20140124, 20100802, 20130819, 20121111, 20140406, 
            20130413, 20130523, 20121204, 20110307, 20140828, 20110912, 
            20101215, 20130129, 20131214, 20120205, 20120119, 20110713, 
            20110427, 20111118, 20101103, 20130916, 20121008, 20111224, 
            20140707, 20130514, 20130622, 20120530, 20121227, 20130228, 
            20120104, 20110412, 20110819, 20140326, 20101004, 20131017, 
            20120909, 20111201, 20100922, 20130615, 20130725, 20120417, 
            20110109, 20140510, 20130327, 20120721, 20110511, 20140920, 
            20140205, 20131122, 20120331, 20120814, 20111030, 20140101, 
            20100915, 20100821, 20130824, 20121116, 20140519, 20140409, 
            20130426, 20120702, 20120622, 20110210, 20110330, 20140823, 
            20110903, 20101206, 20130120, 20131223, 20120228, 20110704, 
            20111007, 20111129, 20100812, 20101120, 20130801, 20130927, 
            20121019, 20140416, 20140708, 20130525, 20120601, 20120523, 
            20121218, 20110309, 20110926, 20130115, 20130221, 20120129, 
            20110405, 20111104, 20110828, 20140303, 20101113, 20101019, 
            20100720, 20130902, 20131026, 20120918, 20111210, 20140717, 
            20140615, 20130624, 20120424, 20110116, 20130214, 20130318, 
            20110502, 20140913, 20110805, 20140228, 20101010, 20131003, 
            20131129, 20120320, 20120821, 20110628, 20140622, 20140114, 
            20100904, 20130723, 20120415, 20121125, 20110107, 20140524, 
            20130309, 20130419, 20120727, 20110203, 20140926, 20140814, 
            20101217, 20131104, 20131228, 20120313, 20120223, 20110731, 
            20111012, 20140123, 20100807, 20130822, 20121114, 20121026, 
            20140427, 20130408, 20130516, 20120624, 20121209, 20140825, 
            20110917, 20101208, 20130106, 20131205, 20120214, 20120122, 
            20110430, 20111115, 20140312, 20101106, 20100729, 20130921, 
            20121013, 20120927, 20111219, 20140726, 20130511, 20130617, 
            20120525, 20130207, 20120115, 20110814, 20140321, 20140219, 
            20101001, 20131020, 20120912, 20120828, 20111204, 20140629, 
            20100929, 20130610, 20130730, 20120422, 20110114, 20140501, 
            20120716, 20110224, 20140919, 20140210, 20131119, 20120302, 
            20120811, 20110722, 20111021, 20140128, 20100830, 20130705, 
            20130831, 20121123, 20140522, 20140402, 20130401, 20120709, 
            20120619, 20110327, 20140816, 20110908, 20101203, 20130125, 
            20131218, 20120201, 20110709, 20110423, 20111002, 20111122, 
            20130804, 20130928, 20121020, 20140421, 20140703, 20130502, 
            20120610, 20120518, 20121223, 20130224, 20110408, 20110516, 
            20111101, 20110823, 20140330, 20101024, 20130907, 20131029, 
            20120921, 20111213, 20140720, 20140604, 20100918, 20130603, 
            20120511, 20120429, 20110121, 20130331, 20110515, 20110217, 
            20140908, 20140201, 20131006, 20131126, 20120327, 20120818, 
            20140619, 20140105, 20100911, 20100817, 20130712, 20120404, 
            20121128, 20140531, 20130430, 20120706, 20110214, 20110318, 
            20140811, 20101226, 20130116, 20131101, 20131227, 20120224, 
            20111011, 20140118, 20100808, 20101116, 20130813, 20121105, 
            20121031, 20140428, 20130529, 20120605, 20121214, 20110313, 
            20110922, 20130111, 20130217, 20120125, 20110401, 20111108, 
            20140307, 20101109, 20101023, 20100724, 20130914, 20121006, 
            20120930, 20111222, 20140729, 20130628, 20120504, 20110128, 
            20130210, 20130322, 20110506, 20140901, 20110809, 20140316, 
            20140224, 20101014, 20131015, 20120316, 20120907, 20120825, 
            20140626, 20130719, 20120411, 20110103, 20140504, 20130313, 
            20130423, 20120731, 20110207, 20140930, 20140802, 20140215, 
            20101221, 20131108, 20120309, 20120219, 20110727, 20111016, 
            20140127, 20100803, 20130818, 20121110, 20140407, 20130412, 
            20130520, 20120628, 20121205, 20110304, 20140829, 20110913, 
            20101212, 20130102, 20131209, 20120210, 20120118, 20110426, 
            20111119, 20101102, 20130917, 20121009, 20111231, 20140706, 
            20130515, 20130621, 20120529, 20121228, 20130203, 20120111, 
            20110818, 20140325, 20101005, 20131016, 20120908, 20140601, 
            20100925, 20130614, 20130726, 20120418, 20110110, 20140513, 
            20130304, 20120720, 20110228, 20140923, 20140206, 20131123, 
            20120330, 20120815, 20110718, 20111025, 20100914, 20100826, 
            20130701, 20130827, 20121119, 20140518, 20140414, 20130405, 
            20120713, 20120623, 20110331, 20140820, 20110904, 20101207, 
            20130121, 20131222, 20110705, 20110419, 20111006, 20111126, 
            20100813, 20101127, 20130924, 20121016, 20140417, 20140715, 
            20130506, 20120614, 20120522, 20121219, 20110927, 20130112, 
            20130220, 20120128, 20110404, 20110520, 20111105, 20110827, 
            20140302, 20101112, 20101028, 20100719, 20130903, 20131025, 
            20120917, 20111209, 20140716, 20140608, 20130607, 20120515, 
            20120425, 20110117, 20130213, 20130319, 20110503, 20110221, 
            20140912, 20110804, 20101011, 20131002, 20131130, 20120323, 
            20120822, 20140623, 20140109, 20100907, 20130708, 20121124, 
            20140527, 20130310, 20130418, 20120726, 20110202, 20110322, 
            20140815, 20101230, 20131105, 20131231, 20120312, 20120220, 
            20110728, 20111015, 20140122, 20100804, 20130809, 20121101, 
            20121027, 20140424, 20130411, 20130517, 20120625, 20121210, 
            20110301, 20110918, 20101209, 20130107, 20131204, 20120215, 
            20120121, 20110429, 20111112, 20140311, 20101105, 20100728, 
            20130910, 20121002, 20120926, 20111218, 20140725, 20130508, 
            20130616, 20120524, 20110124, 20141001, 20130206, 20120114, 
            20140905, 20110813, 20140320, 20140220, 20101002, 20131011, 
            20120903, 20120829, 20140630, 20100928, 20130609, 20130731, 
            20120423, 20110115, 20130301, 20120719, 20110227, 20140918, 
            20140806, 20140211, 20131112, 20120305, 20120804, 20110723, 
            20111020, 20140131, 20100831, 20130706, 20130830, 20121122, 
            20140403, 20120708, 20120616, 20121201, 20110324, 20140817, 
            20110909, 20130130, 20131213, 20120206, 20110714, 20110422, 
            20111123, 20101130, 20130807, 20130929, 20121021, 20111227, 
            20140702, 20130503, 20120611, 20120517, 20121224, 20120107, 
            20110415, 20110517, 20110822, 20140329, 20101025, 20130904, 
            20131028, 20120920, 20111212, 20140605, 20100921, 20130602, 
            20120510, 20120430, 20110122, 20140509, 20130324, 20110508, 
            20110216, 20140911, 20140202, 20131005, 20131127, 20120326, 
            20120819, 20111029, 20140104, 20100910, 20100822, 20130713, 
            20120405, 20140530, 20140410, 20130425, 20120701, 20110209, 
            20110319, 20140808, 20101227, 20130117, 20131102, 20131226, 
            20120225, 20110701, 20111010, 20111130, 20100809, 20101123, 
            20130812, 20121104, 20121028, 20140429, 20140711, 20130526, 
            20120602, 20121215, 20110310, 20110923, 20130108, 20130216, 
            20131203, 20120124, 20111109, 20110831, 20140306, 20101108, 
            20101016, 20100723, 20130915, 20121007, 20120929, 20111221, 
            20140728, 20140612, 20130627, 20120503, 20110129, 20130209, 
            20130323, 20110507, 20110808, 20140225, 20101015, 20131014, 
            20120319, 20120906, 20120826, 20110627, 20140627, 20140113, 
            20100903, 20130720, 20120412, 20110104, 20140507, 20130314, 
            20130422, 20120730, 20110206, 20140925, 20140803, 20101218, 
            20131109, 20120308, 20120216, 20120801, 20110724, 20111019, 
            20140126, 20130821, 20121113, 20140404, 20130415, 20130521, 
            20120629, 20121206, 20110305, 20140826, 20110914, 20101213, 
            20130103, 20131208, 20120211, 20120117, 20110425, 20111116, 
            20140315, 20101101, 20130922, 20121014, 20111230, 20140705, 
            20130512, 20130620, 20120528, 20121229, 20130202, 20120110, 
            20110817, 20140324, 20140216, 20101006, 20131023, 20120915, 
            20111207, 20140602, 20100924, 20130613, 20130727, 20120419, 
            20110111, 20140512, 20130305, 20120723, 20140922, 20140207, 
            20131116, 20120301, 20120808, 20110719, 20111024, 20140103, 
            20100827, 20130702, 20130826, 20121118, 20140521, 20140415, 
            20130404, 20120712, 20120620, 20110328, 20140821, 20110905, 
            20101204, 20130126, 20131217, 20120202, 20110710, 20110418, 
            20111001, 20111127, 20101126, 20130803, 20130925, 20121017, 
            20140422, 20140714, 20130507, 20120615, 20120521, 20121220, 
            20110928, 20130113, 20130227, 20120103, 20110411, 20110521, 
            20111102, 20110826, 20140301, 20101029, 20100718, 20131024, 
            20120916, 20111208, 20140723, 20140609, 20100917, 20130606, 
            20120514, 20120426, 20110118, 20130212, 20130328, 20110512, 
            20110220, 20140915, 20110803, 20131001, 20120322, 20120823, 
            20110630, 20140616, 20140108, 20100906, 20100818, 20130709, 
            20120401, 20121127, 20140526, 20130311, 20130429, 20120705, 
            20110213, 20110323, 20140812, 20101231, 20131106, 20131230, 
            20120315, 20120221, 20110729, 20111014, 20140117, 20100805, 
            20101119, 20130808, 20121024, 20140425, 20130410, 20130530, 
            20120606, 20121211, 20110314, 20110919, 20130104, 20131207, 
            20120212, 20120120, 20110428, 20111113, 20140310, 20101104, 
            20101020, 20100727, 20130911, 20121003, 20120925, 20111217, 
            20140724, 20130509, 20120507, 20110125, 20141002, 20130205, 
            20120113, 20140904, 20110812, 20140319, 20140221, 20101003, 
            20131010, 20120902, 20120830, 20130608, 20130716, 20120408, 
            20140503, 20130302, 20120718, 20110226, 20140929, 20140807, 
            20140212, 20101222, 20131113, 20120304, 20120805, 20110720, 
            20111023, 20140130, 20100828, 20130707, 20130817, 20121109]
    else:
        x = [20131019, 20130109, 20130315, 20130513, 20130306, 20130703, 
            20130127, 20130504, 20130901, 20130329, 20130710, 20130118, 
            20130531, 20130908, 20130320, 20130717, 20130522, 20130919, 
            20130724, 20130926, 20130215, 20130409, 20130611, 20130406, 
            20130805, 20130225, 20130604, 20131007, 20130810, 20130218, 
            20130629, 20131008, 20130420, 20130819, 20130622, 20131017, 
            20130824, 20130115, 20131026, 20130309, 20130106, 20130511, 
            20130705, 20130125, 20130502, 20130907, 20130331, 20130712, 
            20130116, 20130529, 20130914, 20130322, 20130719, 20130520, 
            20130917, 20130726, 20130924, 20130213, 20130411, 20130206, 
            20130609, 20130807, 20130602, 20131005, 20130425, 20130812, 
            20130216, 20130627, 20131014, 20130422, 20130821, 20130620, 
            20131023, 20130826, 20130113, 20131024, 20130311, 20130104, 
            20130509, 20130302, 20130707, 20130131, 20130905, 20130325, 
            20130714, 20130122, 20130527, 20130912, 20130316, 20130721, 
            20130518, 20130923, 20130728, 20130930, 20130204, 20130402, 
            20130427, 20130814, 20130222, 20130625, 20131012, 20130416, 
            20130823, 20130618, 20131021, 20130828, 20131030, 20130110, 
            20130312, 20130129, 20130514, 20130327, 20130120, 20130525, 
            20130902, 20130318, 20130723, 20130516, 20130921, 20130730, 
            20130928, 20130210, 20130412, 20130203, 20130614, 20130405, 
            20130220, 20130607, 20131002, 20130418, 20130809, 20130616, 
            20131011, 20130830, 20131028, 20130108, 20130314, 20130103, 
            20130512, 20130305, 20130702, 20130126, 20130507, 20130328, 
            20130709, 20130530, 20130911, 20130716, 20130918, 20130208, 
            20130414, 20130201, 20130612, 20130407, 20130802, 20130226, 
            20130605, 20130428, 20130811, 20130219, 20130630, 20131009, 
            20130421, 20130816, 20130623, 20131018, 20130825, 20130114, 
            20131027, 20130308, 20130101, 20130510, 20130307, 20130704, 
            20130124, 20130505, 20130906, 20130330, 20130711, 20130119, 
            20130528, 20130909, 20130321, 20130718, 20130523, 20130916, 
            20130725, 20130927, 20130214, 20130408, 20130207, 20130610, 
            20130401, 20130804, 20130224, 20130603, 20131006, 20130430, 
            20130813, 20130217, 20130628, 20131015, 20130423, 20130818, 
            20130621, 20131016, 20130827, 20130112, 20131025, 20130310, 
            20130107, 20130508, 20130301, 20130706, 20130130, 20130503, 
            20130904, 20130324, 20130713, 20130117, 20130526, 20130915, 
            20130323, 20130720, 20130521, 20130922, 20130727, 20130925, 
            20130212, 20130410, 20130205, 20130608, 20130403, 20130806, 
            20130601, 20131004, 20130424, 20130815, 20130223, 20130626, 
            20131013, 20130417, 20130820, 20130619, 20131022, 20130829, 
            20130105, 20130303, 20130128, 20130501, 20130326, 20130715, 
            20130123, 20130524, 20130913, 20130317, 20130722, 20130519, 
            20130920, 20130729, 20130211, 20130413, 20130228, 20130615, 
            20130426, 20130801, 20130221, 20130624, 20131003, 20130419, 
            20130822, 20130617, 20131020, 20130831, 20131029, 20130111, 
            20130313, 20130102, 20130515, 20130304, 20130701, 20130121, 
            20130506, 20130903, 20130319, 20130708, 20130517, 20130910, 
            20130731, 20130929, 20130209, 20130415, 20130202, 20130613, 
            20130404, 20130803, 20130227, 20130606, 20131001, 20130429, 
            20130808, 20131010, 20130817]
    x = sorted(x)
    prices = []
    dates = []
    for each in x:
        date = str(each)
        year = int(date[0:4])
        month = int(date[4:6])
        day = int(date[6:8])
        tuple = year, month, day
        print(each)
        prices += [file[tuple]]
        dates += [float(each)]
    print(dates)
    print(prices)
    return dates, prices


<mask token>

<mask token>


def get_sentiment(text):
    r = requests.get(
        'https://api.idolondemand.com/1/api/sync/analyzesentiment/v1?apikey=fe6dea49-084f-4cd8-be86-0976baf9a714&text='
         + str(text))
    if r.status_code == 200:
        data2 = json.loads(r.text)
        return data2['aggregate']['score']
    else:
        print('Error return code = ' + r.status_code)


def get_text(url):
    dlst = []
    driver = webdriver.Firefox()
    driver.get(url)
    the_table = driver.find_element_by_id('siteTable')
    elements = the_table.find_elements_by_tag_name('div')
    print(elements)
    for element in elements:
        if len(element.find_elements_by_class_name('title')) > 0:
            text = element.find_element_by_class_name('title').text
            print(text)
            dlst += [text]
    driver.quit()
    return dlst


def graph(x_series, y_series, x_series1, y_series1, color1, color2):
    plt.figure(1)
    plt.plot(x_series, y_series, color1)
    plt.plot(x_series1, y_series1, color2)
    plt.draw()
    plt.show()


def get_graph_data(filename):
    file = open(filename, 'r').read()
    file = eval(file)
    x = []
    y = []
    for each in file:
        x += [each[0] * 10000 + each[1] * 100 + each[2]]
        y += [file[each]]
    if filename == 'bitcoinprices.txt':
        x = [20130403, 20120711, 20120617, 20121202, 20110325, 20140830, 
            20110910, 20101201, 20130131, 20131212, 20120207, 20110715, 
            20110421, 20111120, 20101129, 20130806, 20130918, 20121010, 
            20111226, 20140701, 20120608, 20120516, 20121225, 20120106, 
            20110414, 20110518, 20110821, 20140328, 20101026, 20130905, 
            20131019, 20120911, 20111203, 20140606, 20100920, 20130601, 
            20120509, 20110123, 20140508, 20130325, 20110509, 20110219, 
            20140910, 20140203, 20131004, 20131120, 20120329, 20120812, 
            20111028, 20140107, 20100913, 20100823, 20130714, 20120406, 
            20121130, 20140517, 20140411, 20130424, 20110208, 20110316, 
            20140809, 20110901, 20101224, 20130122, 20131103, 20131221, 
            20110706, 20111005, 20100814, 20101122, 20130815, 20121107, 
            20121029, 20140418, 20140710, 20130527, 20120603, 20121216, 
            20110311, 20110924, 20130109, 20130223, 20131202, 20120131, 
            20110407, 20111106, 20110830, 20140305, 20101115, 20101017, 
            20100722, 20130912, 20121004, 20120928, 20111220, 20140719, 
            20140613, 20130626, 20120502, 20110130, 20130208, 20130316, 
            20140903, 20110807, 20140226, 20101008, 20131013, 20120318, 
            20120905, 20120827, 20110626, 20140620, 20140112, 20100902, 
            20130721, 20120413, 20110105, 20140506, 20130315, 20130417, 
            20120725, 20110201, 20140924, 20101219, 20131110, 20120311, 
            20120217, 20120802, 20110725, 20111018, 20140121, 20100801, 
            20130820, 20121112, 20140405, 20130414, 20130518, 20120626, 
            20121207, 20110302, 20140827, 20110915, 20101210, 20131211, 
            20120208, 20120116, 20110424, 20111117, 20140314, 20100731, 
            20130923, 20121015, 20111229, 20140704, 20130513, 20130619, 
            20120527, 20121230, 20130201, 20120109, 20110816, 20140323, 
            20140217, 20101007, 20131022, 20120914, 20111206, 20140603, 
            20100927, 20130612, 20130728, 20120420, 20110112, 20140515, 
            20130306, 20120722, 20140917, 20140208, 20131117, 20120809, 
            20110716, 20111027, 20140102, 20100824, 20130703, 20130829, 
            20121121, 20140520, 20140412, 20130407, 20120715, 20120621, 
            20110329, 20140818, 20110906, 20101205, 20130127, 20131216, 
            20120203, 20110711, 20110417, 20111124, 20101125, 20130802, 
            20130930, 20121022, 20140423, 20140713, 20130504, 20120612, 
            20120520, 20121221, 20110929, 20130226, 20120102, 20110410, 
            20110522, 20111103, 20110825, 20101030, 20100717, 20130901, 
            20131031, 20120923, 20111215, 20140722, 20140610, 20100916, 
            20130605, 20120513, 20120427, 20110119, 20130329, 20110513, 
            20110223, 20140914, 20110802, 20131124, 20120325, 20120816, 
            20140617, 20140111, 20100909, 20100819, 20130710, 20120402, 
            20121126, 20140529, 20130428, 20120704, 20110212, 20110320, 
            20140813, 20101228, 20130118, 20131107, 20131225, 20120314, 
            20120226, 20110702, 20111009, 20140116, 20100810, 20101118, 
            20130811, 20121103, 20121025, 20140430, 20130531, 20120607, 
            20121212, 20110315, 20110920, 20130105, 20130219, 20131206, 
            20120213, 20120127, 20110403, 20111110, 20140309, 20101111, 
            20101021, 20100726, 20130908, 20120924, 20111216, 20140731, 
            20130630, 20120506, 20110126, 20141003, 20130204, 20130320, 
            20120112, 20110504, 20140907, 20110811, 20140318, 20140222, 
            20101012, 20131009, 20120901, 20120831, 20140624, 20100930, 
            20130717, 20120409, 20110101, 20140502, 20130303, 20130421, 
            20120729, 20110205, 20140928, 20140804, 20140213, 20101223, 
            20131114, 20120307, 20120806, 20110721, 20111022, 20140125, 
            20100829, 20130816, 20121108, 20140401, 20130402, 20130522, 
            20120710, 20120630, 20121203, 20110306, 20140831, 20110911, 
            20101214, 20130128, 20131215, 20120204, 20110712, 20110420, 
            20111121, 20101128, 20130919, 20121011, 20111225, 20130501, 
            20130623, 20120609, 20120531, 20121226, 20120105, 20110413, 
            20110519, 20110820, 20140327, 20101027, 20131018, 20120910, 
            20111202, 20140607, 20100923, 20130724, 20120508, 20120416, 
            20110108, 20140511, 20130326, 20110510, 20110218, 20140921, 
            20140204, 20131121, 20120328, 20120813, 20111031, 20140106, 
            20100912, 20100820, 20130715, 20130825, 20120407, 20121117, 
            20140516, 20140408, 20130427, 20120703, 20110211, 20110317, 
            20140822, 20110902, 20101225, 20130123, 20131220, 20110707, 
            20111004, 20111128, 20100815, 20101121, 20130814, 20130926, 
            20121106, 20121018, 20140419, 20140709, 20130524, 20121217, 
            20110308, 20110925, 20130114, 20130222, 20120130, 20110406, 
            20111107, 20110829, 20140304, 20101114, 20101018, 20100721, 
            20130913, 20131027, 20121005, 20120919, 20111211, 20140718, 
            20140614, 20130625, 20120501, 20110131, 20130215, 20130317, 
            20110501, 20140902, 20110806, 20140227, 20101009, 20131012, 
            20131128, 20120321, 20120904, 20120820, 20110629, 20140621, 
            20140115, 20100905, 20130722, 20120414, 20110106, 20140525, 
            20130308, 20130416, 20120724, 20140927, 20140801, 20101216, 
            20131111, 20131229, 20120310, 20120222, 20120803, 20110730, 
            20111013, 20140120, 20100806, 20130823, 20121115, 20140426, 
            20130409, 20130519, 20120627, 20121208, 20110303, 20140824, 
            20110916, 20101211, 20130101, 20131210, 20120209, 20120123, 
            20111114, 20140313, 20101107, 20100730, 20130920, 20121012, 
            20111228, 20140727, 20130510, 20130618, 20120526, 20121231, 
            20120108, 20110815, 20140322, 20140218, 20131021, 20120913, 
            20111205, 20140628, 20100926, 20130611, 20130729, 20120421, 
            20110113, 20140514, 20130307, 20120717, 20110225, 20140916, 
            20140209, 20131118, 20120303, 20120810, 20110717, 20111026, 
            20140129, 20100825, 20130704, 20130828, 20121120, 20140523, 
            20140413, 20130406, 20120714, 20120618, 20110326, 20140819, 
            20110907, 20101202, 20130124, 20131219, 20110708, 20110416, 
            20111003, 20111125, 20101124, 20130805, 20121023, 20140420, 
            20140712, 20130505, 20120613, 20120519, 20121222, 20110930, 
            20130225, 20120101, 20110409, 20110824, 20140331, 20101031, 
            20130906, 20131030, 20120922, 20111214, 20140721, 20140611, 
            20100919, 20130604, 20120512, 20120428, 20110120, 20130330, 
            20110514, 20110222, 20140909, 20110801, 20131007, 20131125, 
            20120324, 20120817, 20140618, 20140110, 20100908, 20100816, 
            20130711, 20120403, 20121129, 20140528, 20120707, 20110215, 
            20110321, 20140810, 20101229, 20130119, 20131224, 20120227, 
            20110703, 20111008, 20140119, 20100811, 20101117, 20130810, 
            20121102, 20121030, 20130528, 20120604, 20121213, 20110312, 
            20110921, 20130110, 20130218, 20131201, 20120126, 20110402, 
            20111111, 20140308, 20101110, 20101022, 20100725, 20130909, 
            20121001, 20111223, 20140730, 20130629, 20120505, 20110127, 
            20141004, 20130211, 20130321, 20110505, 20140906, 20110810, 
            20140317, 20140223, 20101013, 20131008, 20120317, 20120824, 
            20140625, 20100901, 20130718, 20120410, 20110102, 20140505, 
            20130312, 20130420, 20120728, 20110204, 20140805, 20140214, 
            20101220, 20131115, 20120306, 20120218, 20120807, 20110726, 
            20111017, 20140124, 20100802, 20130819, 20121111, 20140406, 
            20130413, 20130523, 20121204, 20110307, 20140828, 20110912, 
            20101215, 20130129, 20131214, 20120205, 20120119, 20110713, 
            20110427, 20111118, 20101103, 20130916, 20121008, 20111224, 
            20140707, 20130514, 20130622, 20120530, 20121227, 20130228, 
            20120104, 20110412, 20110819, 20140326, 20101004, 20131017, 
            20120909, 20111201, 20100922, 20130615, 20130725, 20120417, 
            20110109, 20140510, 20130327, 20120721, 20110511, 20140920, 
            20140205, 20131122, 20120331, 20120814, 20111030, 20140101, 
            20100915, 20100821, 20130824, 20121116, 20140519, 20140409, 
            20130426, 20120702, 20120622, 20110210, 20110330, 20140823, 
            20110903, 20101206, 20130120, 20131223, 20120228, 20110704, 
            20111007, 20111129, 20100812, 20101120, 20130801, 20130927, 
            20121019, 20140416, 20140708, 20130525, 20120601, 20120523, 
            20121218, 20110309, 20110926, 20130115, 20130221, 20120129, 
            20110405, 20111104, 20110828, 20140303, 20101113, 20101019, 
            20100720, 20130902, 20131026, 20120918, 20111210, 20140717, 
            20140615, 20130624, 20120424, 20110116, 20130214, 20130318, 
            20110502, 20140913, 20110805, 20140228, 20101010, 20131003, 
            20131129, 20120320, 20120821, 20110628, 20140622, 20140114, 
            20100904, 20130723, 20120415, 20121125, 20110107, 20140524, 
            20130309, 20130419, 20120727, 20110203, 20140926, 20140814, 
            20101217, 20131104, 20131228, 20120313, 20120223, 20110731, 
            20111012, 20140123, 20100807, 20130822, 20121114, 20121026, 
            20140427, 20130408, 20130516, 20120624, 20121209, 20140825, 
            20110917, 20101208, 20130106, 20131205, 20120214, 20120122, 
            20110430, 20111115, 20140312, 20101106, 20100729, 20130921, 
            20121013, 20120927, 20111219, 20140726, 20130511, 20130617, 
            20120525, 20130207, 20120115, 20110814, 20140321, 20140219, 
            20101001, 20131020, 20120912, 20120828, 20111204, 20140629, 
            20100929, 20130610, 20130730, 20120422, 20110114, 20140501, 
            20120716, 20110224, 20140919, 20140210, 20131119, 20120302, 
            20120811, 20110722, 20111021, 20140128, 20100830, 20130705, 
            20130831, 20121123, 20140522, 20140402, 20130401, 20120709, 
            20120619, 20110327, 20140816, 20110908, 20101203, 20130125, 
            20131218, 20120201, 20110709, 20110423, 20111002, 20111122, 
            20130804, 20130928, 20121020, 20140421, 20140703, 20130502, 
            20120610, 20120518, 20121223, 20130224, 20110408, 20110516, 
            20111101, 20110823, 20140330, 20101024, 20130907, 20131029, 
            20120921, 20111213, 20140720, 20140604, 20100918, 20130603, 
            20120511, 20120429, 20110121, 20130331, 20110515, 20110217, 
            20140908, 20140201, 20131006, 20131126, 20120327, 20120818, 
            20140619, 20140105, 20100911, 20100817, 20130712, 20120404, 
            20121128, 20140531, 20130430, 20120706, 20110214, 20110318, 
            20140811, 20101226, 20130116, 20131101, 20131227, 20120224, 
            20111011, 20140118, 20100808, 20101116, 20130813, 20121105, 
            20121031, 20140428, 20130529, 20120605, 20121214, 20110313, 
            20110922, 20130111, 20130217, 20120125, 20110401, 20111108, 
            20140307, 20101109, 20101023, 20100724, 20130914, 20121006, 
            20120930, 20111222, 20140729, 20130628, 20120504, 20110128, 
            20130210, 20130322, 20110506, 20140901, 20110809, 20140316, 
            20140224, 20101014, 20131015, 20120316, 20120907, 20120825, 
            20140626, 20130719, 20120411, 20110103, 20140504, 20130313, 
            20130423, 20120731, 20110207, 20140930, 20140802, 20140215, 
            20101221, 20131108, 20120309, 20120219, 20110727, 20111016, 
            20140127, 20100803, 20130818, 20121110, 20140407, 20130412, 
            20130520, 20120628, 20121205, 20110304, 20140829, 20110913, 
            20101212, 20130102, 20131209, 20120210, 20120118, 20110426, 
            20111119, 20101102, 20130917, 20121009, 20111231, 20140706, 
            20130515, 20130621, 20120529, 20121228, 20130203, 20120111, 
            20110818, 20140325, 20101005, 20131016, 20120908, 20140601, 
            20100925, 20130614, 20130726, 20120418, 20110110, 20140513, 
            20130304, 20120720, 20110228, 20140923, 20140206, 20131123, 
            20120330, 20120815, 20110718, 20111025, 20100914, 20100826, 
            20130701, 20130827, 20121119, 20140518, 20140414, 20130405, 
            20120713, 20120623, 20110331, 20140820, 20110904, 20101207, 
            20130121, 20131222, 20110705, 20110419, 20111006, 20111126, 
            20100813, 20101127, 20130924, 20121016, 20140417, 20140715, 
            20130506, 20120614, 20120522, 20121219, 20110927, 20130112, 
            20130220, 20120128, 20110404, 20110520, 20111105, 20110827, 
            20140302, 20101112, 20101028, 20100719, 20130903, 20131025, 
            20120917, 20111209, 20140716, 20140608, 20130607, 20120515, 
            20120425, 20110117, 20130213, 20130319, 20110503, 20110221, 
            20140912, 20110804, 20101011, 20131002, 20131130, 20120323, 
            20120822, 20140623, 20140109, 20100907, 20130708, 20121124, 
            20140527, 20130310, 20130418, 20120726, 20110202, 20110322, 
            20140815, 20101230, 20131105, 20131231, 20120312, 20120220, 
            20110728, 20111015, 20140122, 20100804, 20130809, 20121101, 
            20121027, 20140424, 20130411, 20130517, 20120625, 20121210, 
            20110301, 20110918, 20101209, 20130107, 20131204, 20120215, 
            20120121, 20110429, 20111112, 20140311, 20101105, 20100728, 
            20130910, 20121002, 20120926, 20111218, 20140725, 20130508, 
            20130616, 20120524, 20110124, 20141001, 20130206, 20120114, 
            20140905, 20110813, 20140320, 20140220, 20101002, 20131011, 
            20120903, 20120829, 20140630, 20100928, 20130609, 20130731, 
            20120423, 20110115, 20130301, 20120719, 20110227, 20140918, 
            20140806, 20140211, 20131112, 20120305, 20120804, 20110723, 
            20111020, 20140131, 20100831, 20130706, 20130830, 20121122, 
            20140403, 20120708, 20120616, 20121201, 20110324, 20140817, 
            20110909, 20130130, 20131213, 20120206, 20110714, 20110422, 
            20111123, 20101130, 20130807, 20130929, 20121021, 20111227, 
            20140702, 20130503, 20120611, 20120517, 20121224, 20120107, 
            20110415, 20110517, 20110822, 20140329, 20101025, 20130904, 
            20131028, 20120920, 20111212, 20140605, 20100921, 20130602, 
            20120510, 20120430, 20110122, 20140509, 20130324, 20110508, 
            20110216, 20140911, 20140202, 20131005, 20131127, 20120326, 
            20120819, 20111029, 20140104, 20100910, 20100822, 20130713, 
            20120405, 20140530, 20140410, 20130425, 20120701, 20110209, 
            20110319, 20140808, 20101227, 20130117, 20131102, 20131226, 
            20120225, 20110701, 20111010, 20111130, 20100809, 20101123, 
            20130812, 20121104, 20121028, 20140429, 20140711, 20130526, 
            20120602, 20121215, 20110310, 20110923, 20130108, 20130216, 
            20131203, 20120124, 20111109, 20110831, 20140306, 20101108, 
            20101016, 20100723, 20130915, 20121007, 20120929, 20111221, 
            20140728, 20140612, 20130627, 20120503, 20110129, 20130209, 
            20130323, 20110507, 20110808, 20140225, 20101015, 20131014, 
            20120319, 20120906, 20120826, 20110627, 20140627, 20140113, 
            20100903, 20130720, 20120412, 20110104, 20140507, 20130314, 
            20130422, 20120730, 20110206, 20140925, 20140803, 20101218, 
            20131109, 20120308, 20120216, 20120801, 20110724, 20111019, 
            20140126, 20130821, 20121113, 20140404, 20130415, 20130521, 
            20120629, 20121206, 20110305, 20140826, 20110914, 20101213, 
            20130103, 20131208, 20120211, 20120117, 20110425, 20111116, 
            20140315, 20101101, 20130922, 20121014, 20111230, 20140705, 
            20130512, 20130620, 20120528, 20121229, 20130202, 20120110, 
            20110817, 20140324, 20140216, 20101006, 20131023, 20120915, 
            20111207, 20140602, 20100924, 20130613, 20130727, 20120419, 
            20110111, 20140512, 20130305, 20120723, 20140922, 20140207, 
            20131116, 20120301, 20120808, 20110719, 20111024, 20140103, 
            20100827, 20130702, 20130826, 20121118, 20140521, 20140415, 
            20130404, 20120712, 20120620, 20110328, 20140821, 20110905, 
            20101204, 20130126, 20131217, 20120202, 20110710, 20110418, 
            20111001, 20111127, 20101126, 20130803, 20130925, 20121017, 
            20140422, 20140714, 20130507, 20120615, 20120521, 20121220, 
            20110928, 20130113, 20130227, 20120103, 20110411, 20110521, 
            20111102, 20110826, 20140301, 20101029, 20100718, 20131024, 
            20120916, 20111208, 20140723, 20140609, 20100917, 20130606, 
            20120514, 20120426, 20110118, 20130212, 20130328, 20110512, 
            20110220, 20140915, 20110803, 20131001, 20120322, 20120823, 
            20110630, 20140616, 20140108, 20100906, 20100818, 20130709, 
            20120401, 20121127, 20140526, 20130311, 20130429, 20120705, 
            20110213, 20110323, 20140812, 20101231, 20131106, 20131230, 
            20120315, 20120221, 20110729, 20111014, 20140117, 20100805, 
            20101119, 20130808, 20121024, 20140425, 20130410, 20130530, 
            20120606, 20121211, 20110314, 20110919, 20130104, 20131207, 
            20120212, 20120120, 20110428, 20111113, 20140310, 20101104, 
            20101020, 20100727, 20130911, 20121003, 20120925, 20111217, 
            20140724, 20130509, 20120507, 20110125, 20141002, 20130205, 
            20120113, 20140904, 20110812, 20140319, 20140221, 20101003, 
            20131010, 20120902, 20120830, 20130608, 20130716, 20120408, 
            20140503, 20130302, 20120718, 20110226, 20140929, 20140807, 
            20140212, 20101222, 20131113, 20120304, 20120805, 20110720, 
            20111023, 20140130, 20100828, 20130707, 20130817, 20121109]
    else:
        x = [20131019, 20130109, 20130315, 20130513, 20130306, 20130703, 
            20130127, 20130504, 20130901, 20130329, 20130710, 20130118, 
            20130531, 20130908, 20130320, 20130717, 20130522, 20130919, 
            20130724, 20130926, 20130215, 20130409, 20130611, 20130406, 
            20130805, 20130225, 20130604, 20131007, 20130810, 20130218, 
            20130629, 20131008, 20130420, 20130819, 20130622, 20131017, 
            20130824, 20130115, 20131026, 20130309, 20130106, 20130511, 
            20130705, 20130125, 20130502, 20130907, 20130331, 20130712, 
            20130116, 20130529, 20130914, 20130322, 20130719, 20130520, 
            20130917, 20130726, 20130924, 20130213, 20130411, 20130206, 
            20130609, 20130807, 20130602, 20131005, 20130425, 20130812, 
            20130216, 20130627, 20131014, 20130422, 20130821, 20130620, 
            20131023, 20130826, 20130113, 20131024, 20130311, 20130104, 
            20130509, 20130302, 20130707, 20130131, 20130905, 20130325, 
            20130714, 20130122, 20130527, 20130912, 20130316, 20130721, 
            20130518, 20130923, 20130728, 20130930, 20130204, 20130402, 
            20130427, 20130814, 20130222, 20130625, 20131012, 20130416, 
            20130823, 20130618, 20131021, 20130828, 20131030, 20130110, 
            20130312, 20130129, 20130514, 20130327, 20130120, 20130525, 
            20130902, 20130318, 20130723, 20130516, 20130921, 20130730, 
            20130928, 20130210, 20130412, 20130203, 20130614, 20130405, 
            20130220, 20130607, 20131002, 20130418, 20130809, 20130616, 
            20131011, 20130830, 20131028, 20130108, 20130314, 20130103, 
            20130512, 20130305, 20130702, 20130126, 20130507, 20130328, 
            20130709, 20130530, 20130911, 20130716, 20130918, 20130208, 
            20130414, 20130201, 20130612, 20130407, 20130802, 20130226, 
            20130605, 20130428, 20130811, 20130219, 20130630, 20131009, 
            20130421, 20130816, 20130623, 20131018, 20130825, 20130114, 
            20131027, 20130308, 20130101, 20130510, 20130307, 20130704, 
            20130124, 20130505, 20130906, 20130330, 20130711, 20130119, 
            20130528, 20130909, 20130321, 20130718, 20130523, 20130916, 
            20130725, 20130927, 20130214, 20130408, 20130207, 20130610, 
            20130401, 20130804, 20130224, 20130603, 20131006, 20130430, 
            20130813, 20130217, 20130628, 20131015, 20130423, 20130818, 
            20130621, 20131016, 20130827, 20130112, 20131025, 20130310, 
            20130107, 20130508, 20130301, 20130706, 20130130, 20130503, 
            20130904, 20130324, 20130713, 20130117, 20130526, 20130915, 
            20130323, 20130720, 20130521, 20130922, 20130727, 20130925, 
            20130212, 20130410, 20130205, 20130608, 20130403, 20130806, 
            20130601, 20131004, 20130424, 20130815, 20130223, 20130626, 
            20131013, 20130417, 20130820, 20130619, 20131022, 20130829, 
            20130105, 20130303, 20130128, 20130501, 20130326, 20130715, 
            20130123, 20130524, 20130913, 20130317, 20130722, 20130519, 
            20130920, 20130729, 20130211, 20130413, 20130228, 20130615, 
            20130426, 20130801, 20130221, 20130624, 20131003, 20130419, 
            20130822, 20130617, 20131020, 20130831, 20131029, 20130111, 
            20130313, 20130102, 20130515, 20130304, 20130701, 20130121, 
            20130506, 20130903, 20130319, 20130708, 20130517, 20130910, 
            20130731, 20130929, 20130209, 20130415, 20130202, 20130613, 
            20130404, 20130803, 20130227, 20130606, 20131001, 20130429, 
            20130808, 20131010, 20130817]
    x = sorted(x)
    prices = []
    dates = []
    for each in x:
        date = str(each)
        year = int(date[0:4])
        month = int(date[4:6])
        day = int(date[6:8])
        tuple = year, month, day
        print(each)
        prices += [file[tuple]]
        dates += [float(each)]
    print(dates)
    print(prices)
    return dates, prices


<mask token>
print(date, sentiment)
graph([], [], date, sentiment, 'r', 'b')

__author__ = 'SeanSmith'
<mask token>


def get_sentiment(text):
    r = requests.get(
        'https://api.idolondemand.com/1/api/sync/analyzesentiment/v1?apikey=fe6dea49-084f-4cd8-be86-0976baf9a714&text='
         + str(text))
    if r.status_code == 200:
        data2 = json.loads(r.text)
        return data2['aggregate']['score']
    else:
        print('Error return code = ' + r.status_code)


def get_text(url):
    dlst = []
    driver = webdriver.Firefox()
    driver.get(url)
    the_table = driver.find_element_by_id('siteTable')
    elements = the_table.find_elements_by_tag_name('div')
    print(elements)
    for element in elements:
        if len(element.find_elements_by_class_name('title')) > 0:
            text = element.find_element_by_class_name('title').text
            print(text)
            dlst += [text]
    driver.quit()
    return dlst


def graph(x_series, y_series, x_series1, y_series1, color1, color2):
    plt.figure(1)
    plt.plot(x_series, y_series, color1)
    plt.plot(x_series1, y_series1, color2)
    plt.draw()
    plt.show()


def get_graph_data(filename):
    file = open(filename, 'r').read()
    file = eval(file)
    x = []
    y = []
    for each in file:
        x += [each[0] * 10000 + each[1] * 100 + each[2]]
        y += [file[each]]
    if filename == 'bitcoinprices.txt':
        x = [20130403, 20120711, 20120617, 20121202, 20110325, 20140830, 
            20110910, 20101201, 20130131, 20131212, 20120207, 20110715, 
            20110421, 20111120, 20101129, 20130806, 20130918, 20121010, 
            20111226, 20140701, 20120608, 20120516, 20121225, 20120106, 
            20110414, 20110518, 20110821, 20140328, 20101026, 20130905, 
            20131019, 20120911, 20111203, 20140606, 20100920, 20130601, 
            20120509, 20110123, 20140508, 20130325, 20110509, 20110219, 
            20140910, 20140203, 20131004, 20131120, 20120329, 20120812, 
            20111028, 20140107, 20100913, 20100823, 20130714, 20120406, 
            20121130, 20140517, 20140411, 20130424, 20110208, 20110316, 
            20140809, 20110901, 20101224, 20130122, 20131103, 20131221, 
            20110706, 20111005, 20100814, 20101122, 20130815, 20121107, 
            20121029, 20140418, 20140710, 20130527, 20120603, 20121216, 
            20110311, 20110924, 20130109, 20130223, 20131202, 20120131, 
            20110407, 20111106, 20110830, 20140305, 20101115, 20101017, 
            20100722, 20130912, 20121004, 20120928, 20111220, 20140719, 
            20140613, 20130626, 20120502, 20110130, 20130208, 20130316, 
            20140903, 20110807, 20140226, 20101008, 20131013, 20120318, 
            20120905, 20120827, 20110626, 20140620, 20140112, 20100902, 
            20130721, 20120413, 20110105, 20140506, 20130315, 20130417, 
            20120725, 20110201, 20140924, 20101219, 20131110, 20120311, 
            20120217, 20120802, 20110725, 20111018, 20140121, 20100801, 
            20130820, 20121112, 20140405, 20130414, 20130518, 20120626, 
            20121207, 20110302, 20140827, 20110915, 20101210, 20131211, 
            20120208, 20120116, 20110424, 20111117, 20140314, 20100731, 
            20130923, 20121015, 20111229, 20140704, 20130513, 20130619, 
            20120527, 20121230, 20130201, 20120109, 20110816, 20140323, 
            20140217, 20101007, 20131022, 20120914, 20111206, 20140603, 
            20100927, 20130612, 20130728, 20120420, 20110112, 20140515, 
            20130306, 20120722, 20140917, 20140208, 20131117, 20120809, 
            20110716, 20111027, 20140102, 20100824, 20130703, 20130829, 
            20121121, 20140520, 20140412, 20130407, 20120715, 20120621, 
            20110329, 20140818, 20110906, 20101205, 20130127, 20131216, 
            20120203, 20110711, 20110417, 20111124, 20101125, 20130802, 
            20130930, 20121022, 20140423, 20140713, 20130504, 20120612, 
            20120520, 20121221, 20110929, 20130226, 20120102, 20110410, 
            20110522, 20111103, 20110825, 20101030, 20100717, 20130901, 
            20131031, 20120923, 20111215, 20140722, 20140610, 20100916, 
            20130605, 20120513, 20120427, 20110119, 20130329, 20110513, 
            20110223, 20140914, 20110802, 20131124, 20120325, 20120816, 
            20140617, 20140111, 20100909, 20100819, 20130710, 20120402, 
            20121126, 20140529, 20130428, 20120704, 20110212, 20110320, 
            20140813, 20101228, 20130118, 20131107, 20131225, 20120314, 
            20120226, 20110702, 20111009, 20140116, 20100810, 20101118, 
            20130811, 20121103, 20121025, 20140430, 20130531, 20120607, 
            20121212, 20110315, 20110920, 20130105, 20130219, 20131206, 
            20120213, 20120127, 20110403, 20111110, 20140309, 20101111, 
            20101021, 20100726, 20130908, 20120924, 20111216, 20140731, 
            20130630, 20120506, 20110126, 20141003, 20130204, 20130320, 
            20120112, 20110504, 20140907, 20110811, 20140318, 20140222, 
            20101012, 20131009, 20120901, 20120831, 20140624, 20100930, 
            20130717, 20120409, 20110101, 20140502, 20130303, 20130421, 
            20120729, 20110205, 20140928, 20140804, 20140213, 20101223, 
            20131114, 20120307, 20120806, 20110721, 20111022, 20140125, 
            20100829, 20130816, 20121108, 20140401, 20130402, 20130522, 
            20120710, 20120630, 20121203, 20110306, 20140831, 20110911, 
            20101214, 20130128, 20131215, 20120204, 20110712, 20110420, 
            20111121, 20101128, 20130919, 20121011, 20111225, 20130501, 
            20130623, 20120609, 20120531, 20121226, 20120105, 20110413, 
            20110519, 20110820, 20140327, 20101027, 20131018, 20120910, 
            20111202, 20140607, 20100923, 20130724, 20120508, 20120416, 
            20110108, 20140511, 20130326, 20110510, 20110218, 20140921, 
            20140204, 20131121, 20120328, 20120813, 20111031, 20140106, 
            20100912, 20100820, 20130715, 20130825, 20120407, 20121117, 
            20140516, 20140408, 20130427, 20120703, 20110211, 20110317, 
            20140822, 20110902, 20101225, 20130123, 20131220, 20110707, 
            20111004, 20111128, 20100815, 20101121, 20130814, 20130926, 
            20121106, 20121018, 20140419, 20140709, 20130524, 20121217, 
            20110308, 20110925, 20130114, 20130222, 20120130, 20110406, 
            20111107, 20110829, 20140304, 20101114, 20101018, 20100721, 
            20130913, 20131027, 20121005, 20120919, 20111211, 20140718, 
            20140614, 20130625, 20120501, 20110131, 20130215, 20130317, 
            20110501, 20140902, 20110806, 20140227, 20101009, 20131012, 
            20131128, 20120321, 20120904, 20120820, 20110629, 20140621, 
            20140115, 20100905, 20130722, 20120414, 20110106, 20140525, 
            20130308, 20130416, 20120724, 20140927, 20140801, 20101216, 
            20131111, 20131229, 20120310, 20120222, 20120803, 20110730, 
            20111013, 20140120, 20100806, 20130823, 20121115, 20140426, 
            20130409, 20130519, 20120627, 20121208, 20110303, 20140824, 
            20110916, 20101211, 20130101, 20131210, 20120209, 20120123, 
            20111114, 20140313, 20101107, 20100730, 20130920, 20121012, 
            20111228, 20140727, 20130510, 20130618, 20120526, 20121231, 
            20120108, 20110815, 20140322, 20140218, 20131021, 20120913, 
            20111205, 20140628, 20100926, 20130611, 20130729, 20120421, 
            20110113, 20140514, 20130307, 20120717, 20110225, 20140916, 
            20140209, 20131118, 20120303, 20120810, 20110717, 20111026, 
            20140129, 20100825, 20130704, 20130828, 20121120, 20140523, 
            20140413, 20130406, 20120714, 20120618, 20110326, 20140819, 
            20110907, 20101202, 20130124, 20131219, 20110708, 20110416, 
            20111003, 20111125, 20101124, 20130805, 20121023, 20140420, 
            20140712, 20130505, 20120613, 20120519, 20121222, 20110930, 
            20130225, 20120101, 20110409, 20110824, 20140331, 20101031, 
            20130906, 20131030, 20120922, 20111214, 20140721, 20140611, 
            20100919, 20130604, 20120512, 20120428, 20110120, 20130330, 
            20110514, 20110222, 20140909, 20110801, 20131007, 20131125, 
            20120324, 20120817, 20140618, 20140110, 20100908, 20100816, 
            20130711, 20120403, 20121129, 20140528, 20120707, 20110215, 
            20110321, 20140810, 20101229, 20130119, 20131224, 20120227, 
            20110703, 20111008, 20140119, 20100811, 20101117, 20130810, 
            20121102, 20121030, 20130528, 20120604, 20121213, 20110312, 
            20110921, 20130110, 20130218, 20131201, 20120126, 20110402, 
            20111111, 20140308, 20101110, 20101022, 20100725, 20130909, 
            20121001, 20111223, 20140730, 20130629, 20120505, 20110127, 
            20141004, 20130211, 20130321, 20110505, 20140906, 20110810, 
            20140317, 20140223, 20101013, 20131008, 20120317, 20120824, 
            20140625, 20100901, 20130718, 20120410, 20110102, 20140505, 
            20130312, 20130420, 20120728, 20110204, 20140805, 20140214, 
            20101220, 20131115, 20120306, 20120218, 20120807, 20110726, 
            20111017, 20140124, 20100802, 20130819, 20121111, 20140406, 
            20130413, 20130523, 20121204, 20110307, 20140828, 20110912, 
            20101215, 20130129, 20131214, 20120205, 20120119, 20110713, 
            20110427, 20111118, 20101103, 20130916, 20121008, 20111224, 
            20140707, 20130514, 20130622, 20120530, 20121227, 20130228, 
            20120104, 20110412, 20110819, 20140326, 20101004, 20131017, 
            20120909, 20111201, 20100922, 20130615, 20130725, 20120417, 
            20110109, 20140510, 20130327, 20120721, 20110511, 20140920, 
            20140205, 20131122, 20120331, 20120814, 20111030, 20140101, 
            20100915, 20100821, 20130824, 20121116, 20140519, 20140409, 
            20130426, 20120702, 20120622, 20110210, 20110330, 20140823, 
            20110903, 20101206, 20130120, 20131223, 20120228, 20110704, 
            20111007, 20111129, 20100812, 20101120, 20130801, 20130927, 
            20121019, 20140416, 20140708, 20130525, 20120601, 20120523, 
            20121218, 20110309, 20110926, 20130115, 20130221, 20120129, 
            20110405, 20111104, 20110828, 20140303, 20101113, 20101019, 
            20100720, 20130902, 20131026, 20120918, 20111210, 20140717, 
            20140615, 20130624, 20120424, 20110116, 20130214, 20130318, 
            20110502, 20140913, 20110805, 20140228, 20101010, 20131003, 
            20131129, 20120320, 20120821, 20110628, 20140622, 20140114, 
            20100904, 20130723, 20120415, 20121125, 20110107, 20140524, 
            20130309, 20130419, 20120727, 20110203, 20140926, 20140814, 
            20101217, 20131104, 20131228, 20120313, 20120223, 20110731, 
            20111012, 20140123, 20100807, 20130822, 20121114, 20121026, 
            20140427, 20130408, 20130516, 20120624, 20121209, 20140825, 
            20110917, 20101208, 20130106, 20131205, 20120214, 20120122, 
            20110430, 20111115, 20140312, 20101106, 20100729, 20130921, 
            20121013, 20120927, 20111219, 20140726, 20130511, 20130617, 
            20120525, 20130207, 20120115, 20110814, 20140321, 20140219, 
            20101001, 20131020, 20120912, 20120828, 20111204, 20140629, 
            20100929, 20130610, 20130730, 20120422, 20110114, 20140501, 
            20120716, 20110224, 20140919, 20140210, 20131119, 20120302, 
            20120811, 20110722, 20111021, 20140128, 20100830, 20130705, 
            20130831, 20121123, 20140522, 20140402, 20130401, 20120709, 
            20120619, 20110327, 20140816, 20110908, 20101203, 20130125, 
            20131218, 20120201, 20110709, 20110423, 20111002, 20111122, 
            20130804, 20130928, 20121020, 20140421, 20140703, 20130502, 
            20120610, 20120518, 20121223, 20130224, 20110408, 20110516, 
            20111101, 20110823, 20140330, 20101024, 20130907, 20131029, 
            20120921, 20111213, 20140720, 20140604, 20100918, 20130603, 
            20120511, 20120429, 20110121, 20130331, 20110515, 20110217, 
            20140908, 20140201, 20131006, 20131126, 20120327, 20120818, 
            20140619, 20140105, 20100911, 20100817, 20130712, 20120404, 
            20121128, 20140531, 20130430, 20120706, 20110214, 20110318, 
            20140811, 20101226, 20130116, 20131101, 20131227, 20120224, 
            20111011, 20140118, 20100808, 20101116, 20130813, 20121105, 
            20121031, 20140428, 20130529, 20120605, 20121214, 20110313, 
            20110922, 20130111, 20130217, 20120125, 20110401, 20111108, 
            20140307, 20101109, 20101023, 20100724, 20130914, 20121006, 
            20120930, 20111222, 20140729, 20130628, 20120504, 20110128, 
            20130210, 20130322, 20110506, 20140901, 20110809, 20140316, 
            20140224, 20101014, 20131015, 20120316, 20120907, 20120825, 
            20140626, 20130719, 20120411, 20110103, 20140504, 20130313, 
            20130423, 20120731, 20110207, 20140930, 20140802, 20140215, 
            20101221, 20131108, 20120309, 20120219, 20110727, 20111016, 
            20140127, 20100803, 20130818, 20121110, 20140407, 20130412, 
            20130520, 20120628, 20121205, 20110304, 20140829, 20110913, 
            20101212, 20130102, 20131209, 20120210, 20120118, 20110426, 
            20111119, 20101102, 20130917, 20121009, 20111231, 20140706, 
            20130515, 20130621, 20120529, 20121228, 20130203, 20120111, 
            20110818, 20140325, 20101005, 20131016, 20120908, 20140601, 
            20100925, 20130614, 20130726, 20120418, 20110110, 20140513, 
            20130304, 20120720, 20110228, 20140923, 20140206, 20131123, 
            20120330, 20120815, 20110718, 20111025, 20100914, 20100826, 
            20130701, 20130827, 20121119, 20140518, 20140414, 20130405, 
            20120713, 20120623, 20110331, 20140820, 20110904, 20101207, 
            20130121, 20131222, 20110705, 20110419, 20111006, 20111126, 
            20100813, 20101127, 20130924, 20121016, 20140417, 20140715, 
            20130506, 20120614, 20120522, 20121219, 20110927, 20130112, 
            20130220, 20120128, 20110404, 20110520, 20111105, 20110827, 
            20140302, 20101112, 20101028, 20100719, 20130903, 20131025, 
            20120917, 20111209, 20140716, 20140608, 20130607, 20120515, 
            20120425, 20110117, 20130213, 20130319, 20110503, 20110221, 
            20140912, 20110804, 20101011, 20131002, 20131130, 20120323, 
            20120822, 20140623, 20140109, 20100907, 20130708, 20121124, 
            20140527, 20130310, 20130418, 20120726, 20110202, 20110322, 
            20140815, 20101230, 20131105, 20131231, 20120312, 20120220, 
            20110728, 20111015, 20140122, 20100804, 20130809, 20121101, 
            20121027, 20140424, 20130411, 20130517, 20120625, 20121210, 
            20110301, 20110918, 20101209, 20130107, 20131204, 20120215, 
            20120121, 20110429, 20111112, 20140311, 20101105, 20100728, 
            20130910, 20121002, 20120926, 20111218, 20140725, 20130508, 
            20130616, 20120524, 20110124, 20141001, 20130206, 20120114, 
            20140905, 20110813, 20140320, 20140220, 20101002, 20131011, 
            20120903, 20120829, 20140630, 20100928, 20130609, 20130731, 
            20120423, 20110115, 20130301, 20120719, 20110227, 20140918, 
            20140806, 20140211, 20131112, 20120305, 20120804, 20110723, 
            20111020, 20140131, 20100831, 20130706, 20130830, 20121122, 
            20140403, 20120708, 20120616, 20121201, 20110324, 20140817, 
            20110909, 20130130, 20131213, 20120206, 20110714, 20110422, 
            20111123, 20101130, 20130807, 20130929, 20121021, 20111227, 
            20140702, 20130503, 20120611, 20120517, 20121224, 20120107, 
            20110415, 20110517, 20110822, 20140329, 20101025, 20130904, 
            20131028, 20120920, 20111212, 20140605, 20100921, 20130602, 
            20120510, 20120430, 20110122, 20140509, 20130324, 20110508, 
            20110216, 20140911, 20140202, 20131005, 20131127, 20120326, 
            20120819, 20111029, 20140104, 20100910, 20100822, 20130713, 
            20120405, 20140530, 20140410, 20130425, 20120701, 20110209, 
            20110319, 20140808, 20101227, 20130117, 20131102, 20131226, 
            20120225, 20110701, 20111010, 20111130, 20100809, 20101123, 
            20130812, 20121104, 20121028, 20140429, 20140711, 20130526, 
            20120602, 20121215, 20110310, 20110923, 20130108, 20130216, 
            20131203, 20120124, 20111109, 20110831, 20140306, 20101108, 
            20101016, 20100723, 20130915, 20121007, 20120929, 20111221, 
            20140728, 20140612, 20130627, 20120503, 20110129, 20130209, 
            20130323, 20110507, 20110808, 20140225, 20101015, 20131014, 
            20120319, 20120906, 20120826, 20110627, 20140627, 20140113, 
            20100903, 20130720, 20120412, 20110104, 20140507, 20130314, 
            20130422, 20120730, 20110206, 20140925, 20140803, 20101218, 
            20131109, 20120308, 20120216, 20120801, 20110724, 20111019, 
            20140126, 20130821, 20121113, 20140404, 20130415, 20130521, 
            20120629, 20121206, 20110305, 20140826, 20110914, 20101213, 
            20130103, 20131208, 20120211, 20120117, 20110425, 20111116, 
            20140315, 20101101, 20130922, 20121014, 20111230, 20140705, 
            20130512, 20130620, 20120528, 20121229, 20130202, 20120110, 
            20110817, 20140324, 20140216, 20101006, 20131023, 20120915, 
            20111207, 20140602, 20100924, 20130613, 20130727, 20120419, 
            20110111, 20140512, 20130305, 20120723, 20140922, 20140207, 
            20131116, 20120301, 20120808, 20110719, 20111024, 20140103, 
            20100827, 20130702, 20130826, 20121118, 20140521, 20140415, 
            20130404, 20120712, 20120620, 20110328, 20140821, 20110905, 
            20101204, 20130126, 20131217, 20120202, 20110710, 20110418, 
            20111001, 20111127, 20101126, 20130803, 20130925, 20121017, 
            20140422, 20140714, 20130507, 20120615, 20120521, 20121220, 
            20110928, 20130113, 20130227, 20120103, 20110411, 20110521, 
            20111102, 20110826, 20140301, 20101029, 20100718, 20131024, 
            20120916, 20111208, 20140723, 20140609, 20100917, 20130606, 
            20120514, 20120426, 20110118, 20130212, 20130328, 20110512, 
            20110220, 20140915, 20110803, 20131001, 20120322, 20120823, 
            20110630, 20140616, 20140108, 20100906, 20100818, 20130709, 
            20120401, 20121127, 20140526, 20130311, 20130429, 20120705, 
            20110213, 20110323, 20140812, 20101231, 20131106, 20131230, 
            20120315, 20120221, 20110729, 20111014, 20140117, 20100805, 
            20101119, 20130808, 20121024, 20140425, 20130410, 20130530, 
            20120606, 20121211, 20110314, 20110919, 20130104, 20131207, 
            20120212, 20120120, 20110428, 20111113, 20140310, 20101104, 
            20101020, 20100727, 20130911, 20121003, 20120925, 20111217, 
            20140724, 20130509, 20120507, 20110125, 20141002, 20130205, 
            20120113, 20140904, 20110812, 20140319, 20140221, 20101003, 
            20131010, 20120902, 20120830, 20130608, 20130716, 20120408, 
            20140503, 20130302, 20120718, 20110226, 20140929, 20140807, 
            20140212, 20101222, 20131113, 20120304, 20120805, 20110720, 
            20111023, 20140130, 20100828, 20130707, 20130817, 20121109]
    else:
        x = [20131019, 20130109, 20130315, 20130513, 20130306, 20130703, 
            20130127, 20130504, 20130901, 20130329, 20130710, 20130118, 
            20130531, 20130908, 20130320, 20130717, 20130522, 20130919, 
            20130724, 20130926, 20130215, 20130409, 20130611, 20130406, 
            20130805, 20130225, 20130604, 20131007, 20130810, 20130218, 
            20130629, 20131008, 20130420, 20130819, 20130622, 20131017, 
            20130824, 20130115, 20131026, 20130309, 20130106, 20130511, 
            20130705, 20130125, 20130502, 20130907, 20130331, 20130712, 
            20130116, 20130529, 20130914, 20130322, 20130719, 20130520, 
            20130917, 20130726, 20130924, 20130213, 20130411, 20130206, 
            20130609, 20130807, 20130602, 20131005, 20130425, 20130812, 
            20130216, 20130627, 20131014, 20130422, 20130821, 20130620, 
            20131023, 20130826, 20130113, 20131024, 20130311, 20130104, 
            20130509, 20130302, 20130707, 20130131, 20130905, 20130325, 
            20130714, 20130122, 20130527, 20130912, 20130316, 20130721, 
            20130518, 20130923, 20130728, 20130930, 20130204, 20130402, 
            20130427, 20130814, 20130222, 20130625, 20131012, 20130416, 
            20130823, 20130618, 20131021, 20130828, 20131030, 20130110, 
            20130312, 20130129, 20130514, 20130327, 20130120, 20130525, 
            20130902, 20130318, 20130723, 20130516, 20130921, 20130730, 
            20130928, 20130210, 20130412, 20130203, 20130614, 20130405, 
            20130220, 20130607, 20131002, 20130418, 20130809, 20130616, 
            20131011, 20130830, 20131028, 20130108, 20130314, 20130103, 
            20130512, 20130305, 20130702, 20130126, 20130507, 20130328, 
            20130709, 20130530, 20130911, 20130716, 20130918, 20130208, 
            20130414, 20130201, 20130612, 20130407, 20130802, 20130226, 
            20130605, 20130428, 20130811, 20130219, 20130630, 20131009, 
            20130421, 20130816, 20130623, 20131018, 20130825, 20130114, 
            20131027, 20130308, 20130101, 20130510, 20130307, 20130704, 
            20130124, 20130505, 20130906, 20130330, 20130711, 20130119, 
            20130528, 20130909, 20130321, 20130718, 20130523, 20130916, 
            20130725, 20130927, 20130214, 20130408, 20130207, 20130610, 
            20130401, 20130804, 20130224, 20130603, 20131006, 20130430, 
            20130813, 20130217, 20130628, 20131015, 20130423, 20130818, 
            20130621, 20131016, 20130827, 20130112, 20131025, 20130310, 
            20130107, 20130508, 20130301, 20130706, 20130130, 20130503, 
            20130904, 20130324, 20130713, 20130117, 20130526, 20130915, 
            20130323, 20130720, 20130521, 20130922, 20130727, 20130925, 
            20130212, 20130410, 20130205, 20130608, 20130403, 20130806, 
            20130601, 20131004, 20130424, 20130815, 20130223, 20130626, 
            20131013, 20130417, 20130820, 20130619, 20131022, 20130829, 
            20130105, 20130303, 20130128, 20130501, 20130326, 20130715, 
            20130123, 20130524, 20130913, 20130317, 20130722, 20130519, 
            20130920, 20130729, 20130211, 20130413, 20130228, 20130615, 
            20130426, 20130801, 20130221, 20130624, 20131003, 20130419, 
            20130822, 20130617, 20131020, 20130831, 20131029, 20130111, 
            20130313, 20130102, 20130515, 20130304, 20130701, 20130121, 
            20130506, 20130903, 20130319, 20130708, 20130517, 20130910, 
            20130731, 20130929, 20130209, 20130415, 20130202, 20130613, 
            20130404, 20130803, 20130227, 20130606, 20131001, 20130429, 
            20130808, 20131010, 20130817]
    x = sorted(x)
    prices = []
    dates = []
    for each in x:
        date = str(each)
        year = int(date[0:4])
        month = int(date[4:6])
        day = int(date[6:8])
        tuple = year, month, day
        print(each)
        prices += [file[tuple]]
        dates += [float(each)]
    print(dates)
    print(prices)
    return dates, prices


dates, prices = get_graph_data('bitcoinprices.txt')
date, sentiment = get_graph_data('sentiment.txt')
print(date, sentiment)
graph([], [], date, sentiment, 'r', 'b')

__author__ = 'SeanSmith'
from pprint import pprint
import requests, json
import selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
from matplotlib import pyplot as plt
import datetime


def get_sentiment(text):
    r = requests.get(
        'https://api.idolondemand.com/1/api/sync/analyzesentiment/v1?apikey=fe6dea49-084f-4cd8-be86-0976baf9a714&text='
         + str(text))
    if r.status_code == 200:
        data2 = json.loads(r.text)
        return data2['aggregate']['score']
    else:
        print('Error return code = ' + r.status_code)


def get_text(url):
    dlst = []
    driver = webdriver.Firefox()
    driver.get(url)
    the_table = driver.find_element_by_id('siteTable')
    elements = the_table.find_elements_by_tag_name('div')
    print(elements)
    for element in elements:
        if len(element.find_elements_by_class_name('title')) > 0:
            text = element.find_element_by_class_name('title').text
            print(text)
            dlst += [text]
    driver.quit()
    return dlst


def graph(x_series, y_series, x_series1, y_series1, color1, color2):
    plt.figure(1)
    plt.plot(x_series, y_series, color1)
    plt.plot(x_series1, y_series1, color2)
    plt.draw()
    plt.show()


def get_graph_data(filename):
    file = open(filename, 'r').read()
    file = eval(file)
    x = []
    y = []
    for each in file:
        x += [each[0] * 10000 + each[1] * 100 + each[2]]
        y += [file[each]]
    if filename == 'bitcoinprices.txt':
        x = [20130403, 20120711, 20120617, 20121202, 20110325, 20140830, 
            20110910, 20101201, 20130131, 20131212, 20120207, 20110715, 
            20110421, 20111120, 20101129, 20130806, 20130918, 20121010, 
            20111226, 20140701, 20120608, 20120516, 20121225, 20120106, 
            20110414, 20110518, 20110821, 20140328, 20101026, 20130905, 
            20131019, 20120911, 20111203, 20140606, 20100920, 20130601, 
            20120509, 20110123, 20140508, 20130325, 20110509, 20110219, 
            20140910, 20140203, 20131004, 20131120, 20120329, 20120812, 
            20111028, 20140107, 20100913, 20100823, 20130714, 20120406, 
            20121130, 20140517, 20140411, 20130424, 20110208, 20110316, 
            20140809, 20110901, 20101224, 20130122, 20131103, 20131221, 
            20110706, 20111005, 20100814, 20101122, 20130815, 20121107, 
            20121029, 20140418, 20140710, 20130527, 20120603, 20121216, 
            20110311, 20110924, 20130109, 20130223, 20131202, 20120131, 
            20110407, 20111106, 20110830, 20140305, 20101115, 20101017, 
            20100722, 20130912, 20121004, 20120928, 20111220, 20140719, 
            20140613, 20130626, 20120502, 20110130, 20130208, 20130316, 
            20140903, 20110807, 20140226, 20101008, 20131013, 20120318, 
            20120905, 20120827, 20110626, 20140620, 20140112, 20100902, 
            20130721, 20120413, 20110105, 20140506, 20130315, 20130417, 
            20120725, 20110201, 20140924, 20101219, 20131110, 20120311, 
            20120217, 20120802, 20110725, 20111018, 20140121, 20100801, 
            20130820, 20121112, 20140405, 20130414, 20130518, 20120626, 
            20121207, 20110302, 20140827, 20110915, 20101210, 20131211, 
            20120208, 20120116, 20110424, 20111117, 20140314, 20100731, 
            20130923, 20121015, 20111229, 20140704, 20130513, 20130619, 
            20120527, 20121230, 20130201, 20120109, 20110816, 20140323, 
            20140217, 20101007, 20131022, 20120914, 20111206, 20140603, 
            20100927, 20130612, 20130728, 20120420, 20110112, 20140515, 
            20130306, 20120722, 20140917, 20140208, 20131117, 20120809, 
            20110716, 20111027, 20140102, 20100824, 20130703, 20130829, 
            20121121, 20140520, 20140412, 20130407, 20120715, 20120621, 
            20110329, 20140818, 20110906, 20101205, 20130127, 20131216, 
            20120203, 20110711, 20110417, 20111124, 20101125, 20130802, 
            20130930, 20121022, 20140423, 20140713, 20130504, 20120612, 
            20120520, 20121221, 20110929, 20130226, 20120102, 20110410, 
            20110522, 20111103, 20110825, 20101030, 20100717, 20130901, 
            20131031, 20120923, 20111215, 20140722, 20140610, 20100916, 
            20130605, 20120513, 20120427, 20110119, 20130329, 20110513, 
            20110223, 20140914, 20110802, 20131124, 20120325, 20120816, 
            20140617, 20140111, 20100909, 20100819, 20130710, 20120402, 
            20121126, 20140529, 20130428, 20120704, 20110212, 20110320, 
            20140813, 20101228, 20130118, 20131107, 20131225, 20120314, 
            20120226, 20110702, 20111009, 20140116, 20100810, 20101118, 
            20130811, 20121103, 20121025, 20140430, 20130531, 20120607, 
            20121212, 20110315, 20110920, 20130105, 20130219, 20131206, 
            20120213, 20120127, 20110403, 20111110, 20140309, 20101111, 
            20101021, 20100726, 20130908, 20120924, 20111216, 20140731, 
            20130630, 20120506, 20110126, 20141003, 20130204, 20130320, 
            20120112, 20110504, 20140907, 20110811, 20140318, 20140222, 
            20101012, 20131009, 20120901, 20120831, 20140624, 20100930, 
            20130717, 20120409, 20110101, 20140502, 20130303, 20130421, 
            20120729, 20110205, 20140928, 20140804, 20140213, 20101223, 
            20131114, 20120307, 20120806, 20110721, 20111022, 20140125, 
            20100829, 20130816, 20121108, 20140401, 20130402, 20130522, 
            20120710, 20120630, 20121203, 20110306, 20140831, 20110911, 
            20101214, 20130128, 20131215, 20120204, 20110712, 20110420, 
            20111121, 20101128, 20130919, 20121011, 20111225, 20130501, 
            20130623, 20120609, 20120531, 20121226, 20120105, 20110413, 
            20110519, 20110820, 20140327, 20101027, 20131018, 20120910, 
            20111202, 20140607, 20100923, 20130724, 20120508, 20120416, 
            20110108, 20140511, 20130326, 20110510, 20110218, 20140921, 
            20140204, 20131121, 20120328, 20120813, 20111031, 20140106, 
            20100912, 20100820, 20130715, 20130825, 20120407, 20121117, 
            20140516, 20140408, 20130427, 20120703, 20110211, 20110317, 
            20140822, 20110902, 20101225, 20130123, 20131220, 20110707, 
            20111004, 20111128, 20100815, 20101121, 20130814, 20130926, 
            20121106, 20121018, 20140419, 20140709, 20130524, 20121217, 
            20110308, 20110925, 20130114, 20130222, 20120130, 20110406, 
            20111107, 20110829, 20140304, 20101114, 20101018, 20100721, 
            20130913, 20131027, 20121005, 20120919, 20111211, 20140718, 
            20140614, 20130625, 20120501, 20110131, 20130215, 20130317, 
            20110501, 20140902, 20110806, 20140227, 20101009, 20131012, 
            20131128, 20120321, 20120904, 20120820, 20110629, 20140621, 
            20140115, 20100905, 20130722, 20120414, 20110106, 20140525, 
            20130308, 20130416, 20120724, 20140927, 20140801, 20101216, 
            20131111, 20131229, 20120310, 20120222, 20120803, 20110730, 
            20111013, 20140120, 20100806, 20130823, 20121115, 20140426, 
            20130409, 20130519, 20120627, 20121208, 20110303, 20140824, 
            20110916, 20101211, 20130101, 20131210, 20120209, 20120123, 
            20111114, 20140313, 20101107, 20100730, 20130920, 20121012, 
            20111228, 20140727, 20130510, 20130618, 20120526, 20121231, 
            20120108, 20110815, 20140322, 20140218, 20131021, 20120913, 
            20111205, 20140628, 20100926, 20130611, 20130729, 20120421, 
            20110113, 20140514, 20130307, 20120717, 20110225, 20140916, 
            20140209, 20131118, 20120303, 20120810, 20110717, 20111026, 
            20140129, 20100825, 20130704, 20130828, 20121120, 20140523, 
            20140413, 20130406, 20120714, 20120618, 20110326, 20140819, 
            20110907, 20101202, 20130124, 20131219, 20110708, 20110416, 
            20111003, 20111125, 20101124, 20130805, 20121023, 20140420, 
            20140712, 20130505, 20120613, 20120519, 20121222, 20110930, 
            20130225, 20120101, 20110409, 20110824, 20140331, 20101031, 
            20130906, 20131030, 20120922, 20111214, 20140721, 20140611, 
            20100919, 20130604, 20120512, 20120428, 20110120, 20130330, 
            20110514, 20110222, 20140909, 20110801, 20131007, 20131125, 
            20120324, 20120817, 20140618, 20140110, 20100908, 20100816, 
            20130711, 20120403, 20121129, 20140528, 20120707, 20110215, 
            20110321, 20140810, 20101229, 20130119, 20131224, 20120227, 
            20110703, 20111008, 20140119, 20100811, 20101117, 20130810, 
            20121102, 20121030, 20130528, 20120604, 20121213, 20110312, 
            20110921, 20130110, 20130218, 20131201, 20120126, 20110402, 
            20111111, 20140308, 20101110, 20101022, 20100725, 20130909, 
            20121001, 20111223, 20140730, 20130629, 20120505, 20110127, 
            20141004, 20130211, 20130321, 20110505, 20140906, 20110810, 
            20140317, 20140223, 20101013, 20131008, 20120317, 20120824, 
            20140625, 20100901, 20130718, 20120410, 20110102, 20140505, 
            20130312, 20130420, 20120728, 20110204, 20140805, 20140214, 
            20101220, 20131115, 20120306, 20120218, 20120807, 20110726, 
            20111017, 20140124, 20100802, 20130819, 20121111, 20140406, 
            20130413, 20130523, 20121204, 20110307, 20140828, 20110912, 
            20101215, 20130129, 20131214, 20120205, 20120119, 20110713, 
            20110427, 20111118, 20101103, 20130916, 20121008, 20111224, 
            20140707, 20130514, 20130622, 20120530, 20121227, 20130228, 
            20120104, 20110412, 20110819, 20140326, 20101004, 20131017, 
            20120909, 20111201, 20100922, 20130615, 20130725, 20120417, 
            20110109, 20140510, 20130327, 20120721, 20110511, 20140920, 
            20140205, 20131122, 20120331, 20120814, 20111030, 20140101, 
            20100915, 20100821, 20130824, 20121116, 20140519, 20140409, 
            20130426, 20120702, 20120622, 20110210, 20110330, 20140823, 
            20110903, 20101206, 20130120, 20131223, 20120228, 20110704, 
            20111007, 20111129, 20100812, 20101120, 20130801, 20130927, 
            20121019, 20140416, 20140708, 20130525, 20120601, 20120523, 
            20121218, 20110309, 20110926, 20130115, 20130221, 20120129, 
            20110405, 20111104, 20110828, 20140303, 20101113, 20101019, 
            20100720, 20130902, 20131026, 20120918, 20111210, 20140717, 
            20140615, 20130624, 20120424, 20110116, 20130214, 20130318, 
            20110502, 20140913, 20110805, 20140228, 20101010, 20131003, 
            20131129, 20120320, 20120821, 20110628, 20140622, 20140114, 
            20100904, 20130723, 20120415, 20121125, 20110107, 20140524, 
            20130309, 20130419, 20120727, 20110203, 20140926, 20140814, 
            20101217, 20131104, 20131228, 20120313, 20120223, 20110731, 
            20111012, 20140123, 20100807, 20130822, 20121114, 20121026, 
            20140427, 20130408, 20130516, 20120624, 20121209, 20140825, 
            20110917, 20101208, 20130106, 20131205, 20120214, 20120122, 
            20110430, 20111115, 20140312, 20101106, 20100729, 20130921, 
            20121013, 20120927, 20111219, 20140726, 20130511, 20130617, 
            20120525, 20130207, 20120115, 20110814, 20140321, 20140219, 
            20101001, 20131020, 20120912, 20120828, 20111204, 20140629, 
            20100929, 20130610, 20130730, 20120422, 20110114, 20140501, 
            20120716, 20110224, 20140919, 20140210, 20131119, 20120302, 
            20120811, 20110722, 20111021, 20140128, 20100830, 20130705, 
            20130831, 20121123, 20140522, 20140402, 20130401, 20120709, 
            20120619, 20110327, 20140816, 20110908, 20101203, 20130125, 
            20131218, 20120201, 20110709, 20110423, 20111002, 20111122, 
            20130804, 20130928, 20121020, 20140421, 20140703, 20130502, 
            20120610, 20120518, 20121223, 20130224, 20110408, 20110516, 
            20111101, 20110823, 20140330, 20101024, 20130907, 20131029, 
            20120921, 20111213, 20140720, 20140604, 20100918, 20130603, 
            20120511, 20120429, 20110121, 20130331, 20110515, 20110217, 
            20140908, 20140201, 20131006, 20131126, 20120327, 20120818, 
            20140619, 20140105, 20100911, 20100817, 20130712, 20120404, 
            20121128, 20140531, 20130430, 20120706, 20110214, 20110318, 
            20140811, 20101226, 20130116, 20131101, 20131227, 20120224, 
            20111011, 20140118, 20100808, 20101116, 20130813, 20121105, 
            20121031, 20140428, 20130529, 20120605, 20121214, 20110313, 
            20110922, 20130111, 20130217, 20120125, 20110401, 20111108, 
            20140307, 20101109, 20101023, 20100724, 20130914, 20121006, 
            20120930, 20111222, 20140729, 20130628, 20120504, 20110128, 
            20130210, 20130322, 20110506, 20140901, 20110809, 20140316, 
            20140224, 20101014, 20131015, 20120316, 20120907, 20120825, 
            20140626, 20130719, 20120411, 20110103, 20140504, 20130313, 
            20130423, 20120731, 20110207, 20140930, 20140802, 20140215, 
            20101221, 20131108, 20120309, 20120219, 20110727, 20111016, 
            20140127, 20100803, 20130818, 20121110, 20140407, 20130412, 
            20130520, 20120628, 20121205, 20110304, 20140829, 20110913, 
            20101212, 20130102, 20131209, 20120210, 20120118, 20110426, 
            20111119, 20101102, 20130917, 20121009, 20111231, 20140706, 
            20130515, 20130621, 20120529, 20121228, 20130203, 20120111, 
            20110818, 20140325, 20101005, 20131016, 20120908, 20140601, 
            20100925, 20130614, 20130726, 20120418, 20110110, 20140513, 
            20130304, 20120720, 20110228, 20140923, 20140206, 20131123, 
            20120330, 20120815, 20110718, 20111025, 20100914, 20100826, 
            20130701, 20130827, 20121119, 20140518, 20140414, 20130405, 
            20120713, 20120623, 20110331, 20140820, 20110904, 20101207, 
            20130121, 20131222, 20110705, 20110419, 20111006, 20111126, 
            20100813, 20101127, 20130924, 20121016, 20140417, 20140715, 
            20130506, 20120614, 20120522, 20121219, 20110927, 20130112, 
            20130220, 20120128, 20110404, 20110520, 20111105, 20110827, 
            20140302, 20101112, 20101028, 20100719, 20130903, 20131025, 
            20120917, 20111209, 20140716, 20140608, 20130607, 20120515, 
            20120425, 20110117, 20130213, 20130319, 20110503, 20110221, 
            20140912, 20110804, 20101011, 20131002, 20131130, 20120323, 
            20120822, 20140623, 20140109, 20100907, 20130708, 20121124, 
            20140527, 20130310, 20130418, 20120726, 20110202, 20110322, 
            20140815, 20101230, 20131105, 20131231, 20120312, 20120220, 
            20110728, 20111015, 20140122, 20100804, 20130809, 20121101, 
            20121027, 20140424, 20130411, 20130517, 20120625, 20121210, 
            20110301, 20110918, 20101209, 20130107, 20131204, 20120215, 
            20120121, 20110429, 20111112, 20140311, 20101105, 20100728, 
            20130910, 20121002, 20120926, 20111218, 20140725, 20130508, 
            20130616, 20120524, 20110124, 20141001, 20130206, 20120114, 
            20140905, 20110813, 20140320, 20140220, 20101002, 20131011, 
            20120903, 20120829, 20140630, 20100928, 20130609, 20130731, 
            20120423, 20110115, 20130301, 20120719, 20110227, 20140918, 
            20140806, 20140211, 20131112, 20120305, 20120804, 20110723, 
            20111020, 20140131, 20100831, 20130706, 20130830, 20121122, 
            20140403, 20120708, 20120616, 20121201, 20110324, 20140817, 
            20110909, 20130130, 20131213, 20120206, 20110714, 20110422, 
            20111123, 20101130, 20130807, 20130929, 20121021, 20111227, 
            20140702, 20130503, 20120611, 20120517, 20121224, 20120107, 
            20110415, 20110517, 20110822, 20140329, 20101025, 20130904, 
            20131028, 20120920, 20111212, 20140605, 20100921, 20130602, 
            20120510, 20120430, 20110122, 20140509, 20130324, 20110508, 
            20110216, 20140911, 20140202, 20131005, 20131127, 20120326, 
            20120819, 20111029, 20140104, 20100910, 20100822, 20130713, 
            20120405, 20140530, 20140410, 20130425, 20120701, 20110209, 
            20110319, 20140808, 20101227, 20130117, 20131102, 20131226, 
            20120225, 20110701, 20111010, 20111130, 20100809, 20101123, 
            20130812, 20121104, 20121028, 20140429, 20140711, 20130526, 
            20120602, 20121215, 20110310, 20110923, 20130108, 20130216, 
            20131203, 20120124, 20111109, 20110831, 20140306, 20101108, 
            20101016, 20100723, 20130915, 20121007, 20120929, 20111221, 
            20140728, 20140612, 20130627, 20120503, 20110129, 20130209, 
            20130323, 20110507, 20110808, 20140225, 20101015, 20131014, 
            20120319, 20120906, 20120826, 20110627, 20140627, 20140113, 
            20100903, 20130720, 20120412, 20110104, 20140507, 20130314, 
            20130422, 20120730, 20110206, 20140925, 20140803, 20101218, 
            20131109, 20120308, 20120216, 20120801, 20110724, 20111019, 
            20140126, 20130821, 20121113, 20140404, 20130415, 20130521, 
            20120629, 20121206, 20110305, 20140826, 20110914, 20101213, 
            20130103, 20131208, 20120211, 20120117, 20110425, 20111116, 
            20140315, 20101101, 20130922, 20121014, 20111230, 20140705, 
            20130512, 20130620, 20120528, 20121229, 20130202, 20120110, 
            20110817, 20140324, 20140216, 20101006, 20131023, 20120915, 
            20111207, 20140602, 20100924, 20130613, 20130727, 20120419, 
            20110111, 20140512, 20130305, 20120723, 20140922, 20140207, 
            20131116, 20120301, 20120808, 20110719, 20111024, 20140103, 
            20100827, 20130702, 20130826, 20121118, 20140521, 20140415, 
            20130404, 20120712, 20120620, 20110328, 20140821, 20110905, 
            20101204, 20130126, 20131217, 20120202, 20110710, 20110418, 
            20111001, 20111127, 20101126, 20130803, 20130925, 20121017, 
            20140422, 20140714, 20130507, 20120615, 20120521, 20121220, 
            20110928, 20130113, 20130227, 20120103, 20110411, 20110521, 
            20111102, 20110826, 20140301, 20101029, 20100718, 20131024, 
            20120916, 20111208, 20140723, 20140609, 20100917, 20130606, 
            20120514, 20120426, 20110118, 20130212, 20130328, 20110512, 
            20110220, 20140915, 20110803, 20131001, 20120322, 20120823, 
            20110630, 20140616, 20140108, 20100906, 20100818, 20130709, 
            20120401, 20121127, 20140526, 20130311, 20130429, 20120705, 
            20110213, 20110323, 20140812, 20101231, 20131106, 20131230, 
            20120315, 20120221, 20110729, 20111014, 20140117, 20100805, 
            20101119, 20130808, 20121024, 20140425, 20130410, 20130530, 
            20120606, 20121211, 20110314, 20110919, 20130104, 20131207, 
            20120212, 20120120, 20110428, 20111113, 20140310, 20101104, 
            20101020, 20100727, 20130911, 20121003, 20120925, 20111217, 
            20140724, 20130509, 20120507, 20110125, 20141002, 20130205, 
            20120113, 20140904, 20110812, 20140319, 20140221, 20101003, 
            20131010, 20120902, 20120830, 20130608, 20130716, 20120408, 
            20140503, 20130302, 20120718, 20110226, 20140929, 20140807, 
            20140212, 20101222, 20131113, 20120304, 20120805, 20110720, 
            20111023, 20140130, 20100828, 20130707, 20130817, 20121109]
    else:
        x = [20131019, 20130109, 20130315, 20130513, 20130306, 20130703, 
            20130127, 20130504, 20130901, 20130329, 20130710, 20130118, 
            20130531, 20130908, 20130320, 20130717, 20130522, 20130919, 
            20130724, 20130926, 20130215, 20130409, 20130611, 20130406, 
            20130805, 20130225, 20130604, 20131007, 20130810, 20130218, 
            20130629, 20131008, 20130420, 20130819, 20130622, 20131017, 
            20130824, 20130115, 20131026, 20130309, 20130106, 20130511, 
            20130705, 20130125, 20130502, 20130907, 20130331, 20130712, 
            20130116, 20130529, 20130914, 20130322, 20130719, 20130520, 
            20130917, 20130726, 20130924, 20130213, 20130411, 20130206, 
            20130609, 20130807, 20130602, 20131005, 20130425, 20130812, 
            20130216, 20130627, 20131014, 20130422, 20130821, 20130620, 
            20131023, 20130826, 20130113, 20131024, 20130311, 20130104, 
            20130509, 20130302, 20130707, 20130131, 20130905, 20130325, 
            20130714, 20130122, 20130527, 20130912, 20130316, 20130721, 
            20130518, 20130923, 20130728, 20130930, 20130204, 20130402, 
            20130427, 20130814, 20130222, 20130625, 20131012, 20130416, 
            20130823, 20130618, 20131021, 20130828, 20131030, 20130110, 
            20130312, 20130129, 20130514, 20130327, 20130120, 20130525, 
            20130902, 20130318, 20130723, 20130516, 20130921, 20130730, 
            20130928, 20130210, 20130412, 20130203, 20130614, 20130405, 
            20130220, 20130607, 20131002, 20130418, 20130809, 20130616, 
            20131011, 20130830, 20131028, 20130108, 20130314, 20130103, 
            20130512, 20130305, 20130702, 20130126, 20130507, 20130328, 
            20130709, 20130530, 20130911, 20130716, 20130918, 20130208, 
            20130414, 20130201, 20130612, 20130407, 20130802, 20130226, 
            20130605, 20130428, 20130811, 20130219, 20130630, 20131009, 
            20130421, 20130816, 20130623, 20131018, 20130825, 20130114, 
            20131027, 20130308, 20130101, 20130510, 20130307, 20130704, 
            20130124, 20130505, 20130906, 20130330, 20130711, 20130119, 
            20130528, 20130909, 20130321, 20130718, 20130523, 20130916, 
            20130725, 20130927, 20130214, 20130408, 20130207, 20130610, 
            20130401, 20130804, 20130224, 20130603, 20131006, 20130430, 
            20130813, 20130217, 20130628, 20131015, 20130423, 20130818, 
            20130621, 20131016, 20130827, 20130112, 20131025, 20130310, 
            20130107, 20130508, 20130301, 20130706, 20130130, 20130503, 
            20130904, 20130324, 20130713, 20130117, 20130526, 20130915, 
            20130323, 20130720, 20130521, 20130922, 20130727, 20130925, 
            20130212, 20130410, 20130205, 20130608, 20130403, 20130806, 
            20130601, 20131004, 20130424, 20130815, 20130223, 20130626, 
            20131013, 20130417, 20130820, 20130619, 20131022, 20130829, 
            20130105, 20130303, 20130128, 20130501, 20130326, 20130715, 
            20130123, 20130524, 20130913, 20130317, 20130722, 20130519, 
            20130920, 20130729, 20130211, 20130413, 20130228, 20130615, 
            20130426, 20130801, 20130221, 20130624, 20131003, 20130419, 
            20130822, 20130617, 20131020, 20130831, 20131029, 20130111, 
            20130313, 20130102, 20130515, 20130304, 20130701, 20130121, 
            20130506, 20130903, 20130319, 20130708, 20130517, 20130910, 
            20130731, 20130929, 20130209, 20130415, 20130202, 20130613, 
            20130404, 20130803, 20130227, 20130606, 20131001, 20130429, 
            20130808, 20131010, 20130817]
    x = sorted(x)
    prices = []
    dates = []
    for each in x:
        date = str(each)
        year = int(date[0:4])
        month = int(date[4:6])
        day = int(date[6:8])
        tuple = year, month, day
        print(each)
        prices += [file[tuple]]
        dates += [float(each)]
    print(dates)
    print(prices)
    return dates, prices


dates, prices = get_graph_data('bitcoinprices.txt')
date, sentiment = get_graph_data('sentiment.txt')
print(date, sentiment)
graph([], [], date, sentiment, 'r', 'b')

__author__ = 'SeanSmith'


from pprint import pprint
import requests, json
import selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
from matplotlib import pyplot as plt
import datetime


#Format
#{"importance": 0-10, "sentiment": positive/negative/neutral, "score":0-1}
#

def get_sentiment(text):
    r = requests.get("https://api.idolondemand.com/1/api/sync/analyzesentiment/v1?apikey=fe6dea49-084f-4cd8-be86-0976baf9a714&text="+str(text))

    if(r.status_code == 200):
        #print(r.text)
        data2 = json.loads(r.text)
        #pprint(data2)

        return data2['aggregate']['score']
    else:
        print("Error return code = "+r.status_code)




def get_text(url):
    dlst = []
    driver = webdriver.Firefox()
    driver.get(url)
    the_table = driver.find_element_by_id("siteTable")
    elements = the_table.find_elements_by_tag_name("div")
    print(elements)
    for element in elements:
        if(len(element.find_elements_by_class_name("title"))>0):
            text = element.find_element_by_class_name("title").text
            print(text)
            dlst += [text]

    driver.quit()
    return dlst



#counter= 0

#text = get_text("http://www.reddit.com/r/Bitcoin/")
#print(text)
#for each in text:
    #counter += get_sentiment(each)

#print(counter)


def graph(x_series, y_series, x_series1, y_series1, color1, color2):
    plt.figure( 1 )
    plt.plot(x_series, y_series, color1)
    plt.plot(x_series1, y_series1, color2)
    plt.draw()
    plt.show()


def get_graph_data(filename):
    file = open(filename, 'r').read()
    file = eval(file)



    x = []
    y = []
    for each in file:

        x += [each[0]*10000+each[1]*100+each[2]]
        y += [file[each]]


    if(filename == 'bitcoinprices.txt'):
        x = [20130403, 20120711, 20120617, 20121202, 20110325, 20140830, 20110910, 20101201, 20130131, 20131212, 20120207, 20110715, 20110421, 20111120, 20101129, 20130806, 20130918, 20121010, 20111226, 20140701, 20120608, 20120516, 20121225, 20120106, 20110414, 20110518, 20110821, 20140328, 20101026, 20130905, 20131019, 20120911, 20111203, 20140606, 20100920, 20130601, 20120509, 20110123, 20140508, 20130325, 20110509, 20110219, 20140910, 20140203, 20131004, 20131120, 20120329, 20120812, 20111028, 20140107, 20100913, 20100823, 20130714, 20120406, 20121130, 20140517, 20140411, 20130424, 20110208, 20110316, 20140809, 20110901, 20101224, 20130122, 20131103, 20131221, 20110706, 20111005, 20100814, 20101122, 20130815, 20121107, 20121029, 20140418, 20140710, 20130527, 20120603, 20121216, 20110311, 20110924, 20130109, 20130223, 20131202, 20120131, 20110407, 20111106, 20110830, 20140305, 20101115, 20101017, 20100722, 20130912, 20121004, 20120928, 20111220, 20140719, 20140613, 20130626, 20120502, 20110130, 20130208, 20130316, 20140903, 20110807, 20140226, 20101008, 20131013, 20120318, 20120905, 20120827, 20110626, 20140620, 20140112, 20100902, 20130721, 20120413, 20110105, 20140506, 20130315, 20130417, 20120725, 20110201, 20140924, 20101219, 20131110, 20120311, 20120217, 20120802, 20110725, 20111018, 20140121, 20100801, 20130820, 20121112, 20140405, 20130414, 20130518, 20120626, 20121207, 20110302, 20140827, 20110915, 20101210, 20131211, 20120208, 20120116, 20110424, 20111117, 20140314, 20100731, 20130923, 20121015, 20111229, 20140704, 20130513, 20130619, 20120527, 20121230, 20130201, 20120109, 20110816, 20140323, 20140217, 20101007, 20131022, 20120914, 20111206, 20140603, 20100927, 20130612, 20130728, 20120420, 20110112, 20140515, 20130306, 20120722, 20140917, 20140208, 20131117, 20120809, 20110716, 20111027, 20140102, 20100824, 20130703, 20130829, 20121121, 20140520, 20140412, 20130407, 20120715, 20120621, 20110329, 20140818, 20110906, 20101205, 20130127, 20131216, 20120203, 20110711, 20110417, 20111124, 20101125, 20130802, 20130930, 20121022, 20140423, 20140713, 20130504, 20120612, 20120520, 20121221, 20110929, 20130226, 20120102, 20110410, 20110522, 20111103, 20110825, 20101030, 20100717, 20130901, 20131031, 20120923, 20111215, 20140722, 20140610, 20100916, 20130605, 20120513, 20120427, 20110119, 20130329, 20110513, 20110223, 20140914, 20110802, 20131124, 20120325, 20120816, 20140617, 20140111, 20100909, 20100819, 20130710, 20120402, 20121126, 20140529, 20130428, 20120704, 20110212, 20110320, 20140813, 20101228, 20130118, 20131107, 20131225, 20120314, 20120226, 20110702, 20111009, 20140116, 20100810, 20101118, 20130811, 20121103, 20121025, 20140430, 20130531, 20120607, 20121212, 20110315, 20110920, 20130105, 20130219, 20131206, 20120213, 20120127, 20110403, 20111110, 20140309, 20101111, 20101021, 20100726, 20130908, 20120924, 20111216, 20140731, 20130630, 20120506, 20110126, 20141003, 20130204, 20130320, 20120112, 20110504, 20140907, 20110811, 20140318, 20140222, 20101012, 20131009, 20120901, 20120831, 20140624, 20100930, 20130717, 20120409, 20110101, 20140502, 20130303, 20130421, 20120729, 20110205, 20140928, 20140804, 20140213, 20101223, 20131114, 20120307, 20120806, 20110721, 20111022, 20140125, 20100829, 20130816, 20121108, 20140401, 20130402, 20130522, 20120710, 20120630, 20121203, 20110306, 20140831, 20110911, 20101214, 20130128, 20131215, 20120204, 20110712, 20110420, 20111121, 20101128, 20130919, 20121011, 20111225, 20130501, 20130623, 20120609, 20120531, 20121226, 20120105, 20110413, 20110519, 20110820, 20140327, 20101027, 20131018, 20120910, 20111202, 20140607, 20100923, 20130724, 20120508, 20120416, 20110108, 20140511, 20130326, 20110510, 20110218, 20140921, 20140204, 20131121, 20120328, 20120813, 20111031, 20140106, 20100912, 20100820, 20130715, 20130825, 20120407, 20121117, 20140516, 20140408, 20130427, 20120703, 20110211, 20110317, 20140822, 20110902, 20101225, 20130123, 20131220, 20110707, 20111004, 20111128, 20100815, 20101121, 20130814, 20130926, 20121106, 20121018, 20140419, 20140709, 20130524, 20121217, 20110308, 20110925, 20130114, 20130222, 20120130, 20110406, 20111107, 20110829, 20140304, 20101114, 20101018, 20100721, 20130913, 20131027, 20121005, 20120919, 20111211, 20140718, 20140614, 20130625, 20120501, 20110131, 20130215, 20130317, 20110501, 20140902, 20110806, 20140227, 20101009, 20131012, 20131128, 20120321, 20120904, 20120820, 20110629, 20140621, 20140115, 20100905, 20130722, 20120414, 20110106, 20140525, 20130308, 20130416, 20120724, 20140927, 20140801, 20101216, 20131111, 20131229, 20120310, 20120222, 20120803, 20110730, 20111013, 20140120, 20100806, 20130823, 20121115, 20140426, 20130409, 20130519, 20120627, 20121208, 20110303, 20140824, 20110916, 20101211, 20130101, 20131210, 20120209, 20120123, 20111114, 20140313, 20101107, 20100730, 20130920, 20121012, 20111228, 20140727, 20130510, 20130618, 20120526, 20121231, 20120108, 20110815, 20140322, 20140218, 20131021, 20120913, 20111205, 20140628, 20100926, 20130611, 20130729, 20120421, 20110113, 20140514, 20130307, 20120717, 20110225, 20140916, 20140209, 20131118, 20120303, 20120810, 20110717, 20111026, 20140129, 20100825, 20130704, 20130828, 20121120, 20140523, 20140413, 20130406, 20120714, 20120618, 20110326, 20140819, 20110907, 20101202, 20130124, 20131219, 20110708, 20110416, 20111003, 20111125, 20101124, 20130805, 20121023, 20140420, 20140712, 20130505, 20120613, 20120519, 20121222, 20110930, 20130225, 20120101, 20110409, 20110824, 20140331, 20101031, 20130906, 20131030, 20120922, 20111214, 20140721, 20140611, 20100919, 20130604, 20120512, 20120428, 20110120, 20130330, 20110514, 20110222, 20140909, 20110801, 20131007, 20131125, 20120324, 20120817, 20140618, 20140110, 20100908, 20100816, 20130711, 20120403, 20121129, 20140528, 20120707, 20110215, 20110321, 20140810, 20101229, 20130119, 20131224, 20120227, 20110703, 20111008, 20140119, 20100811, 20101117, 20130810, 20121102, 20121030, 20130528, 20120604, 20121213, 20110312, 20110921, 20130110, 20130218, 20131201, 20120126, 20110402, 20111111, 20140308, 20101110, 20101022, 20100725, 20130909, 20121001, 20111223, 20140730, 20130629, 20120505, 20110127, 20141004, 20130211, 20130321, 20110505, 20140906, 20110810, 20140317, 20140223, 20101013, 20131008, 20120317, 20120824, 20140625, 20100901, 20130718, 20120410, 20110102, 20140505, 20130312, 20130420, 20120728, 20110204, 20140805, 20140214, 20101220, 20131115, 20120306, 20120218, 20120807, 20110726, 20111017, 20140124, 20100802, 20130819, 20121111, 20140406, 20130413, 20130523, 20121204, 20110307, 20140828, 20110912, 20101215, 20130129, 20131214, 20120205, 20120119, 20110713, 20110427, 20111118, 20101103, 20130916, 20121008, 20111224, 20140707, 20130514, 20130622, 20120530, 20121227, 20130228, 20120104, 20110412, 20110819, 20140326, 20101004, 20131017, 20120909, 20111201, 20100922, 20130615, 20130725, 20120417, 20110109, 20140510, 20130327, 20120721, 20110511, 20140920, 20140205, 20131122, 20120331, 20120814, 20111030, 20140101, 20100915, 20100821, 20130824, 20121116, 20140519, 20140409, 20130426, 20120702, 20120622, 20110210, 20110330, 20140823, 20110903, 20101206, 20130120, 20131223, 20120228, 20110704, 20111007, 20111129, 20100812, 20101120, 20130801, 20130927, 20121019, 20140416, 20140708, 20130525, 20120601, 20120523, 20121218, 20110309, 20110926, 20130115, 20130221, 20120129, 20110405, 20111104, 20110828, 20140303, 20101113, 20101019, 20100720, 20130902, 20131026, 20120918, 20111210, 20140717, 20140615, 20130624, 20120424, 20110116, 20130214, 20130318, 20110502, 20140913, 20110805, 20140228, 20101010, 20131003, 20131129, 20120320, 20120821, 20110628, 20140622, 20140114, 20100904, 20130723, 20120415, 20121125, 20110107, 20140524, 20130309, 20130419, 20120727, 20110203, 20140926, 20140814, 20101217, 20131104, 20131228, 20120313, 20120223, 20110731, 20111012, 20140123, 20100807, 20130822, 20121114, 20121026, 20140427, 20130408, 20130516, 20120624, 20121209, 20140825, 20110917, 20101208, 20130106, 20131205, 20120214, 20120122, 20110430, 20111115, 20140312, 20101106, 20100729, 20130921, 20121013, 20120927, 20111219, 20140726, 20130511, 20130617, 20120525, 20130207, 20120115, 20110814, 20140321, 20140219, 20101001, 20131020, 20120912, 20120828, 20111204, 20140629, 20100929, 20130610, 20130730, 20120422, 20110114, 20140501, 20120716, 20110224, 20140919, 20140210, 20131119, 20120302, 20120811, 20110722, 20111021, 20140128, 20100830, 20130705, 20130831, 20121123, 20140522, 20140402, 20130401, 20120709, 20120619, 20110327, 20140816, 20110908, 20101203, 20130125, 20131218, 20120201, 20110709, 20110423, 20111002, 20111122, 20130804, 20130928, 20121020, 20140421, 20140703, 20130502, 20120610, 20120518, 20121223, 20130224, 20110408, 20110516, 20111101, 20110823, 20140330, 20101024, 20130907, 20131029, 20120921, 20111213, 20140720, 20140604, 20100918, 20130603, 20120511, 20120429, 20110121, 20130331, 20110515, 20110217, 20140908, 20140201, 20131006, 20131126, 20120327, 20120818, 20140619, 20140105, 20100911, 20100817, 20130712, 20120404, 20121128, 20140531, 20130430, 20120706, 20110214, 20110318, 20140811, 20101226, 20130116, 20131101, 20131227, 20120224, 20111011, 20140118, 20100808, 20101116, 20130813, 20121105, 20121031, 20140428, 20130529, 20120605, 20121214, 20110313, 20110922, 20130111, 20130217, 20120125, 20110401, 20111108, 20140307, 20101109, 20101023, 20100724, 20130914, 20121006, 20120930, 20111222, 20140729, 20130628, 20120504, 20110128, 20130210, 20130322, 20110506, 20140901, 20110809, 20140316, 20140224, 20101014, 20131015, 20120316, 20120907, 20120825, 20140626, 20130719, 20120411, 20110103, 20140504, 20130313, 20130423, 20120731, 20110207, 20140930, 20140802, 20140215, 20101221, 20131108, 20120309, 20120219, 20110727, 20111016, 20140127, 20100803, 20130818, 20121110, 20140407, 20130412, 20130520, 20120628, 20121205, 20110304, 20140829, 20110913, 20101212, 20130102, 20131209, 20120210, 20120118, 20110426, 20111119, 20101102, 20130917, 20121009, 20111231, 20140706, 20130515, 20130621, 20120529, 20121228, 20130203, 20120111, 20110818, 20140325, 20101005, 20131016, 20120908, 20140601, 20100925, 20130614, 20130726, 20120418, 20110110, 20140513, 20130304, 20120720, 20110228, 20140923, 20140206, 20131123, 20120330, 20120815, 20110718, 20111025, 20100914, 20100826, 20130701, 20130827, 20121119, 20140518, 20140414, 20130405, 20120713, 20120623, 20110331, 20140820, 20110904, 20101207, 20130121, 20131222, 20110705, 20110419, 20111006, 20111126, 20100813, 20101127, 20130924, 20121016, 20140417, 20140715, 20130506, 20120614, 20120522, 20121219, 20110927, 20130112, 20130220, 20120128, 20110404, 20110520, 20111105, 20110827, 20140302, 20101112, 20101028, 20100719, 20130903, 20131025, 20120917, 20111209, 20140716, 20140608, 20130607, 20120515, 20120425, 20110117, 20130213, 20130319, 20110503, 20110221, 20140912, 20110804, 20101011, 20131002, 20131130, 20120323, 20120822, 20140623, 20140109, 20100907, 20130708, 20121124, 20140527, 20130310, 20130418, 20120726, 20110202, 20110322, 20140815, 20101230, 20131105, 20131231, 20120312, 20120220, 20110728, 20111015, 20140122, 20100804, 20130809, 20121101, 20121027, 20140424, 20130411, 20130517, 20120625, 20121210, 20110301, 20110918, 20101209, 20130107, 20131204, 20120215, 20120121, 20110429, 20111112, 20140311, 20101105, 20100728, 20130910, 20121002, 20120926, 20111218, 20140725, 20130508, 20130616, 20120524, 20110124, 20141001, 20130206, 20120114, 20140905, 20110813, 20140320, 20140220, 20101002, 20131011, 20120903, 20120829, 20140630, 20100928, 20130609, 20130731, 20120423, 20110115, 20130301, 20120719, 20110227, 20140918, 20140806, 20140211, 20131112, 20120305, 20120804, 20110723, 20111020, 20140131, 20100831, 20130706, 20130830, 20121122, 20140403, 20120708, 20120616, 20121201, 20110324, 20140817, 20110909, 20130130, 20131213, 20120206, 20110714, 20110422, 20111123, 20101130, 20130807, 20130929, 20121021, 20111227, 20140702, 20130503, 20120611, 20120517, 20121224, 20120107, 20110415, 20110517, 20110822, 20140329, 20101025, 20130904, 20131028, 20120920, 20111212, 20140605, 20100921, 20130602, 20120510, 20120430, 20110122, 20140509, 20130324, 20110508, 20110216, 20140911, 20140202, 20131005, 20131127, 20120326, 20120819, 20111029, 20140104, 20100910, 20100822, 20130713, 20120405, 20140530, 20140410, 20130425, 20120701, 20110209, 20110319, 20140808, 20101227, 20130117, 20131102, 20131226, 20120225, 20110701, 20111010, 20111130, 20100809, 20101123, 20130812, 20121104, 20121028, 20140429, 20140711, 20130526, 20120602, 20121215, 20110310, 20110923, 20130108, 20130216, 20131203, 20120124, 20111109, 20110831, 20140306, 20101108, 20101016, 20100723, 20130915, 20121007, 20120929, 20111221, 20140728, 20140612, 20130627, 20120503, 20110129, 20130209, 20130323, 20110507, 20110808, 20140225, 20101015, 20131014, 20120319, 20120906, 20120826, 20110627, 20140627, 20140113, 20100903, 20130720, 20120412, 20110104, 20140507, 20130314, 20130422, 20120730, 20110206, 20140925, 20140803, 20101218, 20131109, 20120308, 20120216, 20120801, 20110724, 20111019, 20140126, 20130821, 20121113, 20140404, 20130415, 20130521, 20120629, 20121206, 20110305, 20140826, 20110914, 20101213, 20130103, 20131208, 20120211, 20120117, 20110425, 20111116, 20140315, 20101101, 20130922, 20121014, 20111230, 20140705, 20130512, 20130620, 20120528, 20121229, 20130202, 20120110, 20110817, 20140324, 20140216, 20101006, 20131023, 20120915, 20111207, 20140602, 20100924, 20130613, 20130727, 20120419, 20110111, 20140512, 20130305, 20120723, 20140922, 20140207, 20131116, 20120301, 20120808, 20110719, 20111024, 20140103, 20100827, 20130702, 20130826, 20121118, 20140521, 20140415, 20130404, 20120712, 20120620, 20110328, 20140821, 20110905, 20101204, 20130126, 20131217, 20120202, 20110710, 20110418, 20111001, 20111127, 20101126, 20130803, 20130925, 20121017, 20140422, 20140714, 20130507, 20120615, 20120521, 20121220, 20110928, 20130113, 20130227, 20120103, 20110411, 20110521, 20111102, 20110826, 20140301, 20101029, 20100718, 20131024, 20120916, 20111208, 20140723, 20140609, 20100917, 20130606, 20120514, 20120426, 20110118, 20130212, 20130328, 20110512, 20110220, 20140915, 20110803, 20131001, 20120322, 20120823, 20110630, 20140616, 20140108, 20100906, 20100818, 20130709, 20120401, 20121127, 20140526, 20130311, 20130429, 20120705, 20110213, 20110323, 20140812, 20101231, 20131106, 20131230, 20120315, 20120221, 20110729, 20111014, 20140117, 20100805, 20101119, 20130808, 20121024, 20140425, 20130410, 20130530, 20120606, 20121211, 20110314, 20110919, 20130104, 20131207, 20120212, 20120120, 20110428, 20111113, 20140310, 20101104, 20101020, 20100727, 20130911, 20121003, 20120925, 20111217, 20140724, 20130509, 20120507, 20110125, 20141002, 20130205, 20120113, 20140904, 20110812, 20140319, 20140221, 20101003, 20131010, 20120902, 20120830, 20130608, 20130716, 20120408, 20140503, 20130302, 20120718, 20110226, 20140929, 20140807, 20140212, 20101222, 20131113, 20120304, 20120805, 20110720, 20111023, 20140130, 20100828, 20130707, 20130817, 20121109]
    else:
        x = [20131019, 20130109, 20130315, 20130513, 20130306, 20130703, 20130127, 20130504, 20130901, 20130329, 20130710, 20130118, 20130531, 20130908, 20130320, 20130717, 20130522, 20130919, 20130724, 20130926, 20130215, 20130409, 20130611, 20130406, 20130805, 20130225, 20130604, 20131007, 20130810, 20130218, 20130629, 20131008, 20130420, 20130819, 20130622, 20131017, 20130824, 20130115, 20131026, 20130309, 20130106, 20130511, 20130705, 20130125, 20130502, 20130907, 20130331, 20130712, 20130116, 20130529, 20130914, 20130322, 20130719, 20130520, 20130917, 20130726, 20130924, 20130213, 20130411, 20130206, 20130609, 20130807, 20130602, 20131005, 20130425, 20130812, 20130216, 20130627, 20131014, 20130422, 20130821, 20130620, 20131023, 20130826, 20130113, 20131024, 20130311, 20130104, 20130509, 20130302, 20130707, 20130131, 20130905, 20130325, 20130714, 20130122, 20130527, 20130912, 20130316, 20130721, 20130518, 20130923, 20130728, 20130930, 20130204, 20130402, 20130427, 20130814, 20130222, 20130625, 20131012, 20130416, 20130823, 20130618, 20131021, 20130828, 20131030, 20130110, 20130312, 20130129, 20130514, 20130327, 20130120, 20130525, 20130902, 20130318, 20130723, 20130516, 20130921, 20130730, 20130928, 20130210, 20130412, 20130203, 20130614, 20130405, 20130220, 20130607, 20131002, 20130418, 20130809, 20130616, 20131011, 20130830, 20131028, 20130108, 20130314, 20130103, 20130512, 20130305, 20130702, 20130126, 20130507, 20130328, 20130709, 20130530, 20130911, 20130716, 20130918, 20130208, 20130414, 20130201, 20130612, 20130407, 20130802, 20130226, 20130605, 20130428, 20130811, 20130219, 20130630, 20131009, 20130421, 20130816, 20130623, 20131018, 20130825, 20130114, 20131027, 20130308, 20130101, 20130510, 20130307, 20130704, 20130124, 20130505, 20130906, 20130330, 20130711, 20130119, 20130528, 20130909, 20130321, 20130718, 20130523, 20130916, 20130725, 20130927, 20130214, 20130408, 20130207, 20130610, 20130401, 20130804, 20130224, 20130603, 20131006, 20130430, 20130813, 20130217, 20130628, 20131015, 20130423, 20130818, 20130621, 20131016, 20130827, 20130112, 20131025, 20130310, 20130107, 20130508, 20130301, 20130706, 20130130, 20130503, 20130904, 20130324, 20130713, 20130117, 20130526, 20130915, 20130323, 20130720, 20130521, 20130922, 20130727, 20130925, 20130212, 20130410, 20130205, 20130608, 20130403, 20130806, 20130601, 20131004, 20130424, 20130815, 20130223, 20130626, 20131013, 20130417, 20130820, 20130619, 20131022, 20130829, 20130105, 20130303, 20130128, 20130501, 20130326, 20130715, 20130123, 20130524, 20130913, 20130317, 20130722, 20130519, 20130920, 20130729, 20130211, 20130413, 20130228, 20130615, 20130426, 20130801, 20130221, 20130624, 20131003, 20130419, 20130822, 20130617, 20131020, 20130831, 20131029, 20130111, 20130313, 20130102, 20130515, 20130304, 20130701, 20130121, 20130506, 20130903, 20130319, 20130708, 20130517, 20130910, 20130731, 20130929, 20130209, 20130415, 20130202, 20130613, 20130404, 20130803, 20130227, 20130606, 20131001, 20130429, 20130808, 20131010, 20130817]



    x = sorted(x)


    prices = []
    dates = []

    for each in x:

        date = str(each)
        year = int(date[0:4])
        month = int(date[4:6])
        day = int(date[6:8])
        tuple = (year, month, day)
        print(each)
        prices += [file[tuple]]
        dates += [float(each)]

    print(dates)
    print(prices)
    return dates, prices




dates, prices = get_graph_data('bitcoinprices.txt')

date, sentiment = get_graph_data('sentiment.txt')

print(date, sentiment)
graph([], [], date, sentiment,  "r", "b")


