Skip to content

Instantly share code, notes, and snippets.

@rafaeldalsenter
Created June 6, 2020 13:13
Show Gist options
  • Save rafaeldalsenter/4f43aaf048bb0c70c526f557dfd94611 to your computer and use it in GitHub Desktop.
Save rafaeldalsenter/4f43aaf048bb0c70c526f557dfd94611 to your computer and use it in GitHub Desktop.
import schedule
import time
import datetime
import os
from models.stock import Stock
from scraping import Scraping
from models.quote import Quote
from repo.mongo import Mongo
MINUTES_SCHEDULE = 10
class Heart:
...
def __scraping_task(self):
date_now = datetime.datetime.now()
list_quote = []
print(f'Initializing capture at {date_now}')
for stock in self.__stocks:
print(f'Getting value from {stock.codigo}...')
value = self.__scraping.get_stock_value(stock)
list_quote.append(Quote(stock.codigo, date_now, value))
Mongo().insert_quotes(list_quote)
print('Values inserted in MongoDB database')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment