2020-01-18 15:34:40 +00:00
|
|
|
import logging
|
|
|
|
import sqlite3
|
2020-01-18 18:36:33 +00:00
|
|
|
import time
|
2020-01-18 15:34:40 +00:00
|
|
|
from pathlib import Path
|
|
|
|
from sources.ArsTechnica import ArsTechnica
|
|
|
|
from sources.BBCBusiness import BBCBusiness
|
2020-01-18 18:36:33 +00:00
|
|
|
from sources.BBCTechnology import BBCTechnology
|
2020-01-18 19:47:27 +00:00
|
|
|
from sources.ReutersBusiness import ReutersBusiness
|
|
|
|
from sources.ReutersTechnology import ReutersTechnology
|
2020-01-18 19:59:02 +00:00
|
|
|
from sources.NYTBusiness import NYTBusiness
|
|
|
|
from sources.NYTTechnology import NYTTechnology
|
2020-01-18 20:05:17 +00:00
|
|
|
from sources.ForbesBusiness import ForbesBusiness
|
|
|
|
from sources.ForbesTechnology import ForbesTechnology
|
2020-01-18 21:04:49 +00:00
|
|
|
from sources.FinancialTimes import FinancialTimes
|
2020-01-18 21:10:37 +00:00
|
|
|
from sources.MacWorld import MacWorld
|
2020-01-18 21:16:34 +00:00
|
|
|
from sources.Wired import Wired
|
2020-01-18 21:19:18 +00:00
|
|
|
from sources.Engadget import Engadget
|
2020-01-18 21:20:48 +00:00
|
|
|
from sources.HuffingtonPostBusiness import HuffingtonPostBusiness
|
|
|
|
from sources.HuffingtonPostTechnology import HuffingtonPostTechnology
|
2020-01-18 15:34:40 +00:00
|
|
|
|
|
|
|
DATABASE_PATH = Path("storage.db")
|
2020-01-18 18:36:33 +00:00
|
|
|
GRAB_FREQUENCY = 15
|
|
|
|
GRAB_INTERVAL = 5
|
2020-01-18 15:34:40 +00:00
|
|
|
|
|
|
|
|
2020-01-18 18:36:33 +00:00
|
|
|
def main():
|
|
|
|
try:
|
|
|
|
db = sqlite3.connect(DATABASE_PATH)
|
|
|
|
if not db:
|
|
|
|
raise sqlite3.DatabaseError
|
2020-01-18 15:34:40 +00:00
|
|
|
|
2020-01-18 18:36:33 +00:00
|
|
|
grabbers = [
|
|
|
|
ArsTechnica(db),
|
|
|
|
BBCBusiness(db),
|
|
|
|
BBCTechnology(db),
|
2020-01-18 19:47:27 +00:00
|
|
|
ReutersBusiness(db),
|
|
|
|
ReutersTechnology(db),
|
2020-01-18 19:59:02 +00:00
|
|
|
NYTBusiness(db),
|
|
|
|
NYTTechnology(db),
|
2020-01-18 20:05:17 +00:00
|
|
|
ForbesBusiness(db),
|
|
|
|
ForbesTechnology(db),
|
2020-01-18 21:04:49 +00:00
|
|
|
FinancialTimes(db),
|
2020-01-18 21:10:37 +00:00
|
|
|
MacWorld(db),
|
2020-01-18 21:16:34 +00:00
|
|
|
Wired(db),
|
2020-01-18 21:19:18 +00:00
|
|
|
Engadget(db),
|
2020-01-18 21:20:48 +00:00
|
|
|
HuffingtonPostBusiness(db),
|
|
|
|
HuffingtonPostTechnology(db),
|
2020-01-18 18:36:33 +00:00
|
|
|
]
|
2020-01-18 15:34:40 +00:00
|
|
|
|
2020-01-18 18:36:33 +00:00
|
|
|
while True:
|
|
|
|
for grabber in grabbers:
|
|
|
|
grabber.grab()
|
|
|
|
time.sleep(GRAB_FREQUENCY/GRAB_INTERVAL)
|
2020-01-18 15:34:40 +00:00
|
|
|
|
2020-01-18 18:36:33 +00:00
|
|
|
except sqlite3.Error:
|
|
|
|
logging.error("Could not connect to database.")
|
|
|
|
exit(-1)
|
2020-01-18 15:34:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-01-18 18:36:33 +00:00
|
|
|
logging.basicConfig(level=logging.INFO,format="%(asctime)s %(levelname)-8s %(message)s",datefmt="%Y-%m-%d %H:%M:%S")
|
2020-01-18 15:34:40 +00:00
|
|
|
main()
|