You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.5 KiB

'''
新闻采集模块
'''
from flask import Blueprint,request,render_template,jsonify
import adminProcess
news = Blueprint("news",__name__)
# 新闻的列表页面
@news.route("/admin/result_news")
def result_news():
# 获取来源的参数
page = request.args.get('page')
if page is None: page = 1
# 增加获取一共多少页的代码
data = {}
data['totalPage']=adminProcess.getDataListPage(tableName='news')
data['currentPage'] = int(page)
data['news']=adminProcess.getDataListByPage(tableName='news',page=int(page))
return render_template("admin/news.html",data=data)
'''处理新闻数据采集'''
@news.route("/admin/newsCollect")
def newsCollect():
sourceID = request.args.get('source')
if adminProcess.newsFetch(sourceID):
return jsonify({'code':200,'msg':"爬取成功!"})
else:
return jsonify({'code':200,'msg':'爬取失败!'})
'''处理新闻数据删除'''
@news.route("/admin/newsDelete")
def newsDelete():
id = request.args.get('id')
if adminProcess.newsDelete("news",id):
return jsonify({'code':200,'msg':'删除成功!'})
else:
return jsonify({'code':404,'msg':'删除不成功!'})
'''处理新闻数据显示'''
@news.route("/admin/newsShow")
def newsShow():
id = request.args.get('id')
if adminProcess.newsShow("news",id):
return jsonify({'code':200,'msg':'删除成功!'})
else:
return jsonify({'code':404,'msg':'删除不成功!'})