diff --git a/app/school/__pycache__/index.cpython-36.pyc b/app/school/__pycache__/index.cpython-36.pyc index f987beb9483e81f110fc8cfdebf02cff2ccd2c03..9164715e64190642636b587960fcb3f89233ff83 100644 Binary files a/app/school/__pycache__/index.cpython-36.pyc and b/app/school/__pycache__/index.cpython-36.pyc differ diff --git a/app/school/index.py b/app/school/index.py index b237b6a15fa79cb5267133935c9497c2f8c9f93b..f8dab3537e4f45838b1402d2f15571354e2e3a7a 100644 --- a/app/school/index.py +++ b/app/school/index.py @@ -91,3 +91,11 @@ def ajax_list_school(): pagination = pagination_object(page) return jsonify(pagination) + + +@s.route('pr') +def pull_refresh(): + page = int(request.args.get("page", 1)) + + pagination = pagination_object(page) + return render_template('school/pulltorefresh.html', pagination=pagination) diff --git a/app/slow/__pycache__/index.cpython-36.pyc b/app/slow/__pycache__/index.cpython-36.pyc index 505d704ff28285a837cb63a17d81ffa81855c6ec..46f7f8f6198049837db3f5b655ec57c725edd5a0 100644 Binary files a/app/slow/__pycache__/index.cpython-36.pyc and b/app/slow/__pycache__/index.cpython-36.pyc differ diff --git a/app/templates/index.html b/app/templates/index.html index f1ae7a5aed8a782468e61ffaadcdee309be0728e..b2a853654c022c89112150d7b9df01a1e6068301 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -115,7 +115,27 @@ - +
+
+
+

滚动加载

+
最新更新 +
+
+
+

本案例模拟的滚动加载数据,当使用鼠标滚轮下拉数据到底部时,会自动触发异步函数,调用后台数据。

+

难度:⭐

+

+ 案例: + 学校清单 +

+
+ +
+
@@ -127,9 +147,7 @@

UA 参数反爬

-
最新更新 -
+

该案例要求爬虫程序构造请求头的时候,必须携带 User-Agent 参数,否则会返回403错误。

diff --git a/app/templates/school/pulltorefresh.html b/app/templates/school/pulltorefresh.html new file mode 100644 index 0000000000000000000000000000000000000000..0c268a1cba91892522e4ae76851a9eba4d39e981 --- /dev/null +++ b/app/templates/school/pulltorefresh.html @@ -0,0 +1,65 @@ +{% extends "base.html" %} +{% block script %} + +{% endblock script %} + + +{% block content %} +
+ + {% for school in pagination.data_list %} +
+
+
+
+ + + +
+
+
{{school.name}}
+

+ {% for fea in school.feature.split(',') %} + {{fea}} + {% endfor %} +

+

所在省市:{{school.province}} -- {{school.city}}

+
+
+
+
+ {% endfor %} + +
+ + + + +

+ 下一页数据 +

+ + + +{% endblock %} diff --git a/app/templates/school/pulltorefresh_btn.html b/app/templates/school/pulltorefresh_btn.html new file mode 100644 index 0000000000000000000000000000000000000000..3ca2ee59be6171803f9d0a5595dc3261d49f4c0e --- /dev/null +++ b/app/templates/school/pulltorefresh_btn.html @@ -0,0 +1,71 @@ +{% extends "base.html" %} +{% block script %} + + +{% endblock script %} + + +{% block content %} +
+ + {% for school in pagination.data_list %} +
+
+
+
+ + + +
+
+
{{school.name}}
+

+ {% for fea in school.feature.split(',') %} + {{fea}} + {% endfor %} +

+

所在省市:{{school.province}} -- {{school.city}}

+
+
+
+
+ {% endfor %} + +
+ + +

+ +

+ + +

+ 下一页数据 +

+ + + +{% endblock %}