提交 4599f1d4 编写于 作者: 梦想橡皮擦's avatar 梦想橡皮擦 💬

异步AJAX加密

上级 ae29a78a
...@@ -29,7 +29,6 @@ def error403(): ...@@ -29,7 +29,6 @@ def error403():
def cookie_demo(): def cookie_demo():
if 'story' in request.cookies: if 'story' in request.cookies:
# 如果存在 'story' cookie,则执行相应操作 # 如果存在 'story' cookie,则执行相应操作
# ...
return render_template("antispider/cookie_demo.html") return render_template("antispider/cookie_demo.html")
else: else:
return "没有权限", 403 return "没有权限", 403
...@@ -2,8 +2,10 @@ import math ...@@ -2,8 +2,10 @@ import math
from flask import Blueprint, jsonify, request from flask import Blueprint, jsonify, request
from flask import render_template from flask import render_template
from sqlalchemy import not_, and_, or_ from sqlalchemy import not_, and_, or_,text
from ..model import Csdn # 导入上级模块 from ..model import Csdn # 导入上级模块
from app import db
cs = Blueprint('csdn', __name__, url_prefix='/csdn') cs = Blueprint('csdn', __name__, url_prefix='/csdn')
...@@ -58,8 +60,43 @@ def new_star_list(): ...@@ -58,8 +60,43 @@ def new_star_list():
return render_template('csdn/newstar.html', user=user) return render_template('csdn/newstar.html', user=user)
@cs.route('/oldstar') @cs.route('/zong')
def old_star_list(): def zong_star_list():
user = Csdn.query.order_by(-Csdn.totalScore).filter(not_(Csdn.regtime.startswith("2022"))).all() user = []
t = request.args.get("t", 0)
try:
t = int(t)
except Exception as e:
return "what are you 弄啥嘞? <a href='/'>返回首页</a>", 403
if t == 0:
user = Csdn.query.order_by(-Csdn.totalScore).all()
elif t==1:
user = Csdn.query.order_by(-Csdn.yuanli).all()
elif t == 2:
user = Csdn.query.order_by(-Csdn.fensi).all()
elif t == 3:
user = Csdn.query.order_by(-Csdn.fangwen).all()
elif t == 4:
user = Csdn.query.order_by(-Csdn.yuanchuang).all()
elif t == 5:
user = Csdn.query.order_by(Csdn.zongbang).all()
elif t == 6:
user = Csdn.query.order_by(-Csdn.tie).all()
elif t == 7:
# sql = "SELECT * FROM score ORDER BY CONVERT(ip USING gbk) DESC"
sql = "SELECT * FROM score ORDER BY CONVERT(ip USING gbk) DESC"
result = db.engine.execute(text(sql))
user = [row for row in result]
"""
<a class="btn btn-success" href="/csdn/zong?t=1">按原力排名</a>
<a class="btn btn-success" href="/csdn/zong?t=2">按粉丝排名</a>
<a class="btn btn-success" href="/csdn/zong?t=3">按访问数排名</a>
<a class="btn btn-success" href="/csdn/zong?t=4">按文章数排名</a>
<a class="btn btn-success" href="/csdn/zong?t=5">按总榜数排名</a>
<a class="btn btn-success" href="/csdn/zong?t=6">按铁粉数排名</a>
<a class="btn btn-success" href="/csdn/zong?t=7">按省市排序</a>
"""
return render_template('csdn/oldstar.html', user=user) return render_template('csdn/blogstar_d.html', user=user)
...@@ -49,4 +49,12 @@ class Csdn(db.Model, EntityBase): ...@@ -49,4 +49,12 @@ class Csdn(db.Model, EntityBase):
cateName = db.Column(db.String(255)) cateName = db.Column(db.String(255))
totalScore = db.Column(db.Float) totalScore = db.Column(db.Float)
regtime = db.Column(db.String(255)) regtime = db.Column(db.String(255))
\ No newline at end of file yuanli = db.Column(db.Integer)
fangwen = db.Column(db.Integer)
yuanchuang = db.Column(db.Integer)
zongbang = db.Column(db.Integer)
fensi = db.Column(db.Integer)
tie = db.Column(db.Integer)
ip = db.Column(db.String(255))
import math import math
import base64
import json
from flask import Blueprint, jsonify, request from flask import Blueprint, jsonify, request
from flask import render_template from flask import render_template
...@@ -99,3 +101,30 @@ def pull_refresh(): ...@@ -99,3 +101,30 @@ def pull_refresh():
pagination = pagination_object(page) pagination = pagination_object(page)
return render_template('school/pulltorefresh.html', pagination=pagination) return render_template('school/pulltorefresh.html', pagination=pagination)
"""
简单返回加密
"""
@s.route('encry_list')
def encry_ajax_list():
page = 1 # 初始化第一页数据
pagination = pagination_object(page)
return render_template('school/encry_ajax_list.html', pagination=pagination)
# 加密 API
@s.route('encry_api')
def encry_api():
page = int(request.args.get("page", 1))
pagination = pagination_object(page)
data_bytes = json.dumps(pagination["data_list"]).encode()
# 重新赋值
pagination["data_list"] = base64.b64encode(data_bytes).decode("utf-8")
return jsonify(pagination)
...@@ -6,29 +6,29 @@ ...@@ -6,29 +6,29 @@
<div class="alert alert-warning"> <div class="alert alert-warning">
<p class="m-0"> <p class="m-0">
<strong>CSDN 2022 博客之星总排名</strong> 👉 绿色背景是总分前 200(晋级区)👈</p> <strong>CSDN 2022 博客之星总排名</strong> 👉 绿色背景是总分前 200(晋级区)👈</p>
<p class="text-success p-0"><small>数据同步时间:2023-01-02 18:00</small></p> <p class="text-success p-0"><small>数据同步时间:2023-01-03 12:00</small></p>
<p class="m-0"><small>来都来了,不去给橡皮擦打个5分么?</small> | <a target="_blank" <p class="m-0"><small>来都来了,不去给橡皮擦打个5分么?</small> | <a target="_blank"
href="https://bbs.csdn.net/topics/611387187"><small>https://bbs.csdn.net/topics/611387187</small></a> href="https://bbs.csdn.net/topics/611387187"><small>https://bbs.csdn.net/topics/611387187</small></a>
</p> </p>
</div> </div>
<div class="btn-group btn-group-sm"> <div class="btn-group btn-group-sm">
<a class="btn btn-primary active" href="/csdn/blogstar">总榜</a> <a class="btn btn-primary active" href="/csdn/blogstar">总榜</a>
<!-- <a class="btn btn-primary" href="/csdn/oldstar">博客之星排名</a>--> <a class="btn btn-primary d-none d-sm-block" href="/csdn/zong">总榜详细指标</a>
<a class="btn btn-primary" href="/csdn/newstar">仅看新星</a> <a class="btn btn-primary" href="/csdn/newstar">仅看新星</a>
</div> </div>
<br> <br>
<div class="btn-group btn-group-sm mt-3 d-flex"> <div class="btn-group btn-group-sm mt-3 d-flex">
<a class="btn btn-success" href="/csdn/blogstar?page=1">其它</a> <a class="btn btn-success" href="/csdn/blogstar?page=1">其它</a>
<a class="btn btn-success" href="/csdn/blogstar?page=2">前端</a> <a class="btn btn-success" href="/csdn/blogstar?page=2">前端</a>
<a class="btn btn-success" href="/csdn/blogstar?page=3">后端</a> <a class="btn btn-success" href="/csdn/blogstar?page=3">后端</a>
<a class="btn btn-success" href="/csdn/blogstar?page=4">大数据</a> <a class="btn btn-success" href="/csdn/blogstar?page=4">大数据</a>
<a class="btn btn-success" href="/csdn/blogstar?page=5">云原生</a> <a class="btn btn-success" href="/csdn/blogstar?page=5">云原生</a>
<a class="btn btn-success" href="/csdn/blogstar?page=6">前沿技术</a> <a class="btn btn-success" href="/csdn/blogstar?page=6">前沿技术</a>
<a class="btn btn-success" href="/csdn/blogstar?page=7">人工智能</a> <a class="btn btn-success" href="/csdn/blogstar?page=7">人工智能</a>
<a class="btn btn-success" href="/csdn/blogstar?page=8">运维与安全</a> <a class="btn btn-success" href="/csdn/blogstar?page=8">运维与安全</a>
<a class="btn btn-success" href="/csdn/blogstar?page=9">移动开发</a> <a class="btn btn-success" href="/csdn/blogstar?page=9">移动开发</a>
<a class="btn btn-success" href="/csdn/blogstar?page=10">物联网</a> <a class="btn btn-success" href="/csdn/blogstar?page=10">物联网</a>
</div> </div>
</caption> </caption>
<thead> <thead>
......
{% extends "base.html" %}
{% block content %}
<div class="container">
<table class="table table-hover table-bordered">
<caption class="caption-top text-center">
<div class="alert alert-warning">
<p class="m-0">
<strong>CSDN 2022 博客之星总排名</strong> 👉 绿色背景是总分前 200(晋级区)👈</p>
<p class="text-success p-0"><small>数据同步时间:2023-01-03 12:00</small></p>
<p class="m-0"><small>来都来了,不去给橡皮擦打个5分么?</small> | <a target="_blank"
href="https://bbs.csdn.net/topics/611387187"><small>https://bbs.csdn.net/topics/611387187</small></a>
</p>
</div>
<div class="btn-group btn-group-sm">
<a class="btn btn-primary " href="/csdn/blogstar">总榜</a>
<a class="btn btn-primary d-none d-sm-block active" href="/csdn/zong">总榜详细指标</a>
<a class="btn btn-primary" href="/csdn/newstar">仅看新星</a>
</div>
<br>
<div class="btn-group btn-group-sm mt-3 d-flex">
<a class="btn btn-success" href="/csdn/zong?t=1">按原力排名</a>
<a class="btn btn-success" href="/csdn/zong?t=2">按粉丝排名</a>
<a class="btn btn-success" href="/csdn/zong?t=3">按访问数排名</a>
<a class="btn btn-success" href="/csdn/zong?t=4">按文章数排名</a>
<a class="btn btn-success" href="/csdn/zong?t=5">按总榜数排名</a>
<!-- <a class="btn btn-success" href="/csdn/zong?t=6">按铁粉数排名</a>-->
<a class="btn btn-success" href="/csdn/zong?t=7">按省市排序</a>
</div>
</caption>
<thead>
<tr>
<th>排名</th>
<th>昵称</th>
<th>赛道</th>
<th>总分</th>
<th>注册时间</th>
<th>原力等级</th>
<th>总访问量</th>
<th>原创数</th>
<th>C总榜排名</th>
<th>粉丝数</th>
<th>铁粉数</th>
<th>省市</th>
</tr>
</thead>
<tbody>
{% for u in user %}
<tr>
<td>{{loop.index}}</td>
<td>{{u.nickname}}</td>
<td>
{{u.cateName}}
</td>
<td>{{u.totalScore}}</td>
<td>{{u.regtime}}</td>
<td>{{u.yuanli}}</td>
<td>{{u.fangwen}}</td>
<td>{{u.yuanchuang}}</td>
<td>{{u.zongbang}}</td>
<td>{{u.fensi}}</td>
<td>{{u.tie}}</td>
<td>{{u.ip}}</td>
</tr>
{%endfor%}
</tbody>
</table>
</div>
<div class="card text-center d-none d-sm-block" style="position:fixed;top: 20px;right: 0px;">
<div class="card-header ">2022年博客之星</div>
<div class="card-body">
<div class="alert alert-success">
<p><strong>使用 Ctrl+F 检索自己的昵称即可</strong></p>
<p><a href="https://bbs.csdn.net/topics/611387187" target="_blank" class="btn btn-primary btn-block"
data-bs-toggle="tooltip" title="快点去,快点去!">为【橡皮擦去打个 5 分】</a></p>
<p class="text-danger">数据每天12:00前后同步 <br>得分越多,同步越快</p>
</div>
</div>
<div class="card-footer ">
橡皮擦等你的⭐⭐⭐⭐⭐
</div>
</div>
{% endblock %}
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<div class="alert alert-warning"> <div class="alert alert-warning">
<p class="m-0"> <p class="m-0">
<strong>CSDN 2022 博客新星总排名</strong> 👉 绿色背景是总分前 100(晋级区)👈</p> <strong>CSDN 2022 博客新星总排名</strong> 👉 绿色背景是总分前 100(晋级区)👈</p>
<p class="text-success p-0"><small>数据同步时间:2022-12-30 9:00</small></p> <p class="text-success p-0"><small>数据同步时间:2023-12-30 9:00</small></p>
<p class="m-0"><small>来都来了,不去给橡皮擦打个5分么?</small> | <a target="_blank" <p class="m-0"><small>来都来了,不去给橡皮擦打个5分么?</small> | <a target="_blank"
href="https://bbs.csdn.net/topics/611387187"><small>https://bbs.csdn.net/topics/611387187</small></a> href="https://bbs.csdn.net/topics/611387187"><small>https://bbs.csdn.net/topics/611387187</small></a>
</p> </p>
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</div> </div>
<div class="btn-group btn-group-sm"> <div class="btn-group btn-group-sm">
<a class="btn btn-primary" href="/csdn/blogstar">总榜</a> <a class="btn btn-primary" href="/csdn/blogstar">总榜</a>
<!-- <a class="btn btn-primary" href="/csdn/oldstar">博客之星排名</a>--> <a class="btn btn-primary d-none d-sm-block " href="/csdn/zong">总榜详细指标</a>
<a class="btn btn-primary active" href="/csdn/newstar">仅看新星</a> <a class="btn btn-primary active" href="/csdn/newstar">仅看新星</a>
</div> </div>
</caption> </caption>
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
</p> </p>
</div> </div>
<div class="card-footer text-end"> <div class="card-footer text-end">
<a href="https://blog.csdn.net/hihell/article/details/128420246" target="_blank" class="card-link ">案例制作教程</a>
<a href="#" class="btn btn-primary card-link ">学习博客</a> <a href="#" class="btn btn-primary btn-sm card-link ">学习博客</a>
</div> </div>
</div> </div>
...@@ -45,7 +45,8 @@ ...@@ -45,7 +45,8 @@
</p> </p>
</div> </div>
<div class="card-footer text-end"> <div class="card-footer text-end">
<a href="#" class="btn btn-primary card-link ">学习博客</a> <a href="https://blog.csdn.net/hihell/article/details/128429345" target="_blank" class="card-link ">案例制作教程</a>
<a href="#" class="btn btn-primary card-link btn-sm">学习博客</a>
</div> </div>
</div> </div>
</div> </div>
...@@ -66,7 +67,8 @@ ...@@ -66,7 +67,8 @@
</p> </p>
</div> </div>
<div class="card-footer text-end"> <div class="card-footer text-end">
<a href="#" class="btn btn-primary card-link ">学习博客</a> <a href="https://blog.csdn.net/hihell/article/details/128465888" target="_blank" class="card-link ">案例制作教程</a>
<a href="#" class="btn btn-primary card-link btn-sm">学习博客</a>
</div> </div>
</div> </div>
</div> </div>
...@@ -87,7 +89,8 @@ ...@@ -87,7 +89,8 @@
</p> </p>
</div> </div>
<div class="card-footer text-end"> <div class="card-footer text-end">
<a href="#" class="btn btn-primary card-link ">学习博客</a> <a href="https://blog.csdn.net/hihell/article/details/128474866" target="_blank" class="card-link ">案例制作教程</a>
<a href="#" class="btn btn-primary card-link btn-sm">学习博客</a>
</div> </div>
</div> </div>
</div> </div>
...@@ -111,7 +114,8 @@ ...@@ -111,7 +114,8 @@
</p> </p>
</div> </div>
<div class="card-footer text-end"> <div class="card-footer text-end">
<a href="#" class="btn btn-primary card-link ">学习博客</a> <a href="https://blog.csdn.net/hihell/article/details/128474887" target="_blank" class="card-link ">案例制作教程</a>
<a href="#" class="btn btn-primary card-link btn-sm">学习博客</a>
</div> </div>
</div> </div>
</div> </div>
...@@ -132,10 +136,12 @@ ...@@ -132,10 +136,12 @@
</p> </p>
</div> </div>
<div class="card-footer text-end"> <div class="card-footer text-end">
<a href="#" class="btn btn-primary card-link ">学习博客</a> <a href="https://blog.csdn.net/hihell/article/details/128474916" target="_blank" class="card-link ">案例制作教程</a>
<a href="#" class="btn btn-primary card-link btn-sm">学习博客</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
...@@ -159,7 +165,8 @@ ...@@ -159,7 +165,8 @@
</div> </div>
<div class="card-footer text-end"> <div class="card-footer text-end">
<a href="#" class="btn btn-primary card-link ">学习博客</a> <a href="https://blog.csdn.net/hihell/article/details/128473575" target="_blank" class="card-link ">案例制作教程</a>
<a href="#" class="btn btn-primary card-link btn-sm">学习博客</a>
</div> </div>
</div> </div>
...@@ -181,11 +188,35 @@ ...@@ -181,11 +188,35 @@
</p> </p>
</div> </div>
<div class="card-footer text-end"> <div class="card-footer text-end">
<a href="#" class="btn btn-primary card-link ">学习博客</a> <a href="https://blog.csdn.net/hihell/article/details/128474849"
target="_blank" class="card-link ">案例制作教程</a>
<a href="#" class="btn btn-primary card-link btn-sm">学习博客</a>
</div> </div>
</div> </div>
</div> </div>
<div class="col mt-2">
<div class="card border-info rounded-5 shadow-sm" style="min-height:268px;min-width:300px;">
<div class="card-header text-center">
<h4 class="card-title">简易响应加密</h4>
<div class="bg-danger text-white rounded p-1"
style="transform: rotate(20deg); position:absolute;right:0;top:0.5rem;">最新更新
</div>
</div>
<div class="card-body">
<p class="card-text">本案例请求数据接口之后,会返回加密值,在前台需要对加密串进行解密,然后在渲染数据。</p>
<p class="card-text text-left">难度:⭐⭐</p>
<p class="card-text">
案例:
<a href="/ss/encry_list" class="card-link text-success">学校清单</a>
</p>
</div>
<div class="card-footer text-end">
<a href="https://dream.blog.csdn.net/article/details/128474924" target="_blank" class="card-link ">案例制作教程</a>
<a href="#" class="btn btn-primary card-link btn-sm">学习博客</a>
</div>
</div>
</div>
</div> </div>
</div> </div>
......
{% extends "base.html" %}
{% block script %}
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.6.0.min.js"></script>
<script type="text/javascript">
function get_data(page){
$.ajax({
type: "get",
url: "/ss/encry_api",
data: {
page: page
},
success: function(response) {
// ajax 请求成功
render_data(response);
// 修改分页数据
$('.prev').attr('page',response["prev_page"]);
$('.next').attr('page',response["next_page"]) ;
console.log("AJAX request succeeded!");
},
error: function(error) {
console.log("AJAX request failed: " + error);
}
});
}
function render_data(response){
data_list = response["data_list"];
// base64 解码
const decoded = atob(data_list);
const obj = JSON.parse(decoded);
if(obj.length>0){
$('#school_list').empty();
$.each(obj,function(index,item){
var row = $('<div>', {
'class': 'row mt-3',
'data-custom-attribute': 'value'
});
var col =$('<div>', {
'class': 'col'
});
var d_flex = $('<div>', {
'class': 'd-flex'
});
d_flex.append('<div class="flex-shrink-0"><a href="#"><img class="rounded-pill img-thumbnail" width="64" height="64" src="'+item.pic+'" alt=""></a></div>');
// 生成一下标签代码
var badge = "";
$.each(item.feature.split(','),function(i,f){
badge += ' <span class="badge rounded-pill bg-primary">'+f+'</span> ';
});
d_flex.append('<div class="flex-grow-1 ms-3"><h5 class="float-start pe-3">'+item.name+'</h5><p class="ms-3">'+badge+'</p><p><em>所在省市:<span class="text-black-50">'+item.province+'--'+item.city+'</span></em></p></div>')
col.append(d_flex);
row.append(col);
$('#school_list').append(row);
})
}
}
$(function(){
$('.page-item').on('click',function(){
page = $(this).attr('page');
// 获取数据
get_data(page);
})
})
</script>
{% endblock script %}
{% block content %}
<div class="container" id="school_list">
{% for school in pagination.data_list %}
<div class="row mt-3">
<div class="col">
<div class="d-flex">
<div class="flex-shrink-0">
<a href="#">
<img class="rounded-pill img-thumbnail" width="64" height="64" src="{{school.pic}}" alt="">
</a>
</div>
<div class="flex-grow-1 ms-3">
<h5 class="float-start pe-3">{{school.name}}</h5>
<p class="ms-3">
{% for fea in school.feature.split(',') %}
<span class="badge rounded-pill bg-primary">{{fea}}</span>
{% endfor %}
</p>
<p><em>所在省市:<span class="text-black-50">{{school.province}} -- {{school.city}}</span></em></p>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
<div class="container">
<div class="row">
<div class="col">
<span class="text-dark float-end align-middle"
style="line-height: 40px;">合计 {{pagination.total}} 条数据</span>
<ul class="pagination float-end">
<li class="page-item prev" page="{{pagination.prev_page}}">
<a class="page-link" href="#">上一页</a>
</li>
<li class="page-item next" page="{{ pagination.next_page }}"><a class="page-link"
href="#">下一页</a>
</li>
</ul>
</div>
</div>
</div>
{% endblock %}
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册