from flask import Flask, make_response, request, g, jsonify
import json
import schedule
import medrxiv.get_medrxiv_data as med
import schedule


def do_medrxiv_data():
    print("run!")
    with open("./key.json", 'r') as f:
        keyword = json.loads(f.read())
    print(keyword)
    data = med.get_list(keyword)
    with open("./result.json", 'w') as res:
        json.dump(data, res)


# 定时任务爬虫
def tasklist():
    # 清空任务
    schedule.clear()
    # 创建一个按秒间隔执行任务
    schedule.every(1).hours.do(do_medrxiv_data)
    schedule.run_all()


# 网络编程

app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def get_paper():
    with open("./result.json", 'r') as f:
        temp = json.loads(f.read())
    return jsonify(data=temp)


if __name__ == '__main__':
    do_medrxiv_data()
    app.run(debug=True)

from flask import Flask, make_response, request, g, jsonify
import json
import schedule
import medrxiv.get_medrxiv_data as med
import schedule


def do_medrxiv_data():
    print("run!")
    with open("./key.json", 'r') as f:
        keyword = json.loads(f.read())
    print(keyword)
    data = med.get_list(keyword)
    with open("./result.json", 'w') as res:
        json.dump(data, res)


# 定时任务爬虫
def tasklist():
    # 清空任务
    schedule.clear()
    # 创建一个按秒间隔执行任务
    schedule.every(1).hours.do(do_medrxiv_data)
    schedule.run_all()


# 网络编程

app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def get_paper():
    with open("./result.json", 'r') as f:
        temp = json.loads(f.read())
    return jsonify(data=temp)


if __name__ == '__main__':
    do_medrxiv_data()
    app.run(debug=True)

# 定时任务爬虫 # 清空任务 # 创建一个按秒间隔执行任务 # 网络编程