def collectHistoryDish(self, historyLIs, pair_id, ticker): # print(historyLIs) for li in historyLIs: if li.find('a') is not None and li.find('a').text == '历史数据': history_href = li.find('a').get('href') print(li.find('a').get('href')) historical_url = 'https://cn.investing.com' + history_href print(historical_url) json_o = self.findSmlId(historical_url) pairId = json_o['pairId'] smlId = json_o['smlId'] print(str(pairId) + " : " + str(smlId)) service = ScrapyService() dish_price_list = service.getDishItemHistoryService( ticker, pairId, smlId) miracleService = MiracleService() miracleService.saveDishPriceHistory(dish_price_list) # print(basic_response.text) basic_url = "https://cn.investing.com/instruments/HistoricalDataAjax" service = ScrapyService() basic_response = service.callPostRequst(basic_url, "")
def collectIndexHistory(self, obj): now = datetime.datetime.now() if not self.isHistory: self.st_date = now.strftime("%Y/01/01") post_url = "https://cn.investing.com/instruments/HistoricalDataAjax" service = ScrapyService() dish_price_list = service.getDishItemHistoryService( obj.get("ticker"), obj.get("curr_id"), obj.get("smlID"), self.st_date) miracleService = MiracleService() indexItem = Index() indexItem.setTicker(obj.get("ticker")) indexItem.setDescription(obj.get("description")) miracleService.saveIndexItem(indexItem) miracleService.saveIndexPriceHistory(dish_price_list)