def articles(): page = int(request.args.get('page')) page_size = int(request.args.get('page_size')) language = request.args.get('language') query = request.args.get('query') resp = simplejson.dumps( get_articles(language=language, query=query, page=page, page_size=page_size)) return resp
def get_data_random(): wb = xlrd.open_workbook("stocks.xlsx") # CHANGE THIS!!!!!!! sheet = wb.sheet_by_index(0) ticker = (sheet.cell_value(randint(6, (sheet.nrows)), 1)) date = (str)(datetime.fromtimestamp(int(randint( 1512108000, 1600491600))).date()) # between 2017 and now company_name = "" sector = "" for i in range(5, sheet.nrows, 1): if sheet.cell_value(i, 1) == ticker: company_name = sheet.cell_value(i, 0) sector = sheet.cell_value(i, 5) [opens, highs, lows, volumes, dates] = getChartData(ticker, date) # data = {} vehical_data = {"data": [data]} data['ticker'] = ticker data['company-name'] = company_name data['sector'] = sector name = 'volume' data[name] = volumes data['open'] = opens data['high'] = highs data['low'] = lows data['dates'] = dates data['twitter'] = analyze_tweets(company_name) # data['dividend'] = get_dividend(ticker, date) # data['earnings'] = get_earnings(ticker, date) # data['ratioPerTime'] = calculate_ratios(ticker)["ratiosPerTime"] word_freq_list = news.get_frq_words(news.get_articles(company_name, date)) print(word_freq_list) words = [] freq = [] for a in word_freq_list: words.append(a[0]) freq.append(a[1]) data['news-words'] = words data['news-frequency'] = freq x = jsonify(vehical_data) return build_actual_response(x)
def search(): city = ui.get_city() restaurants = rest.get_restaurants(city) news_articles = news.get_articles(city) weather_forecast = weather.get_forecast(city) ui.display(restaurants, news_articles, weather_forecast) # figure out if user wants to save if user_wants_to_save: db.save(restaurants, news_articles, weather_forecast)
def get_data(ticker, date): [opens, highs, lows, volumes, dates] = getChartData(ticker, date) wb = xlrd.open_workbook("stocks.xlsx") # CHANGE THIS!!!!!!! sheet = wb.sheet_by_index(0) company_name = "" sector = "" for i in range(5, sheet.nrows, 1): if sheet.cell_value(i, 1) == ticker: company_name = sheet.cell_value(i, 0) sector = sheet.cell_value(i, 5) print(sector) data = {} vehical_data = {"data": [data]} name = 'volume' data['company-name'] = company_name data['sector'] = sector data['ticker'] = ticker data[name] = volumes data['open'] = opens data['high'] = highs data['low'] = lows data['dates'] = dates data['twitter'] = analyze_tweets(company_name) word_freq_list = news.get_frq_words(news.get_articles(company_name, date)) # print("-----------------------------------------------------------------------") # # print(word_freq_list) # words = [] freq = [] for a in word_freq_list: words.append(a[0]) freq.append(a[1]) data['news-words'] = words data['news-frequency'] = freq # print(words) # print(freq) x = jsonify(vehical_data) return build_actual_response(x)
def hello_world(): articles = get_articles() return render_template("index.html", articles=articles)