Add script for updating news data on a daily basis
This commit is contained in:
parent
3619a6ec0c
commit
d68783ddda
7
news/Dockerfile
Normal file
7
news/Dockerfile
Normal file
@ -0,0 +1,7 @@
|
||||
FROM python:3.11
|
||||
COPY update_news.py .
|
||||
COPY requirements.txt .
|
||||
RUN pip install -r requirements.txt
|
||||
RUN pip install --index-url https://dev.moshington.com/api/packages/moshferatu/pypi/simple/ database
|
||||
RUN pip install --index-url https://dev.moshington.com/api/packages/moshferatu/pypi/simple/ news
|
||||
CMD ["python", "./update_news.py"]
|
16
news/update_news.py
Normal file
16
news/update_news.py
Normal file
@ -0,0 +1,16 @@
|
||||
import schedule
|
||||
import time
|
||||
|
||||
from database.news import insert
|
||||
from datetime import date
|
||||
from news import scrape_news
|
||||
|
||||
def update_news_data():
|
||||
news_data = scrape_news(date.today())
|
||||
insert(news_data)
|
||||
|
||||
if __name__ == '__main__':
|
||||
schedule.every().day.at('02:00', 'America/Los_Angeles').do(update_news_data)
|
||||
while True:
|
||||
schedule.run_pending()
|
||||
time.sleep(1)
|
Loading…
Reference in New Issue
Block a user