22 lines
626 B
Python
22 lines
626 B
Python
import time
|
|
|
|
from .db import db
|
|
from .models import PaperMetadata
|
|
|
|
|
|
def run_scraper():
|
|
while True:
|
|
with db.app.app_context():
|
|
paper = Paper.query.filter_by(status="Pending").first()
|
|
if paper:
|
|
try:
|
|
# Scraping logic (e.g. download PDF)
|
|
paper.status = "Done"
|
|
paper.file_path = "papers/some_path.pdf"
|
|
except Exception as e:
|
|
paper.status = "Failed"
|
|
paper.error_message = str(e)
|
|
db.session.commit()
|
|
else:
|
|
time.sleep(60)
|