Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦想橡皮擦
爬虫训练场
提交
ae29a78a
爬
爬虫训练场
项目概览
梦想橡皮擦
/
爬虫训练场
通知
64
Star
7
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
爬
爬虫训练场
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
ae29a78a
编写于
1月 03, 2023
作者:
梦想橡皮擦
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
滚动加载
上级
8a877e45
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
166 addition
and
4 deletion
+166
-4
app/school/__pycache__/index.cpython-36.pyc
app/school/__pycache__/index.cpython-36.pyc
+0
-0
app/school/index.py
app/school/index.py
+8
-0
app/slow/__pycache__/index.cpython-36.pyc
app/slow/__pycache__/index.cpython-36.pyc
+0
-0
app/templates/index.html
app/templates/index.html
+22
-4
app/templates/school/pulltorefresh.html
app/templates/school/pulltorefresh.html
+65
-0
app/templates/school/pulltorefresh_btn.html
app/templates/school/pulltorefresh_btn.html
+71
-0
未找到文件。
app/school/__pycache__/index.cpython-36.pyc
浏览文件 @
ae29a78a
无法预览此类型文件
app/school/index.py
浏览文件 @
ae29a78a
...
...
@@ -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
)
app/slow/__pycache__/index.cpython-36.pyc
浏览文件 @
ae29a78a
无法预览此类型文件
app/templates/index.html
浏览文件 @
ae29a78a
...
...
@@ -115,7 +115,27 @@
</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/pr"
class=
"card-link text-success"
>
学校清单
</a>
</p>
</div>
<div
class=
"card-footer text-end"
>
<a
href=
"#"
class=
"btn btn-primary card-link "
>
学习博客
</a>
</div>
</div>
</div>
</div>
</div>
...
...
@@ -127,9 +147,7 @@
<div
class=
"card border-danger rounded-5 shadow-sm"
style=
"min-height:268px;min-width:300px;"
>
<div
class=
"card-header text-center"
>
<h4
class=
"card-title"
>
UA 参数反爬
</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"
>
该案例要求爬虫程序构造请求头的时候,必须携带 User-Agent 参数,否则会返回403错误。
</p>
...
...
app/templates/school/pulltorefresh.html
0 → 100644
浏览文件 @
ae29a78a
{% extends "base.html" %}
{% block script %}
{% endblock script %}
{% block content %}
<div
class=
"container"
>
{% 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>
<!-- status elements -->
<div
class=
"scroller-status"
style=
"display:none;padding-top: 20px;border-top: 1px solid #DDD;text-align: center;color: #777;"
>
<div
class=
"loader-ellips infinite-scroll-request"
>
<span
class=
"loader-ellips__dot"
></span>
<span
class=
"loader-ellips__dot"
></span>
<span
class=
"loader-ellips__dot"
></span>
<span
class=
"loader-ellips__dot"
></span>
</div>
<p
class=
"infinite-scroll-last"
>
数据到底了
</p>
<p
class=
"infinite-scroll-error"
>
加载失败
</p>
</div>
<!-- pagination has path -->
<p
class=
"pagination"
>
<a
class=
"pagination__next"
href=
"/ss/pr?page={{pagination.next_page}}"
>
下一页数据
</a>
</p>
<script
src=
"https://unpkg.com/infinite-scroll@3/dist/infinite-scroll.pkgd.min.js"
></script>
<script
type=
"text/javascript"
>
const
infiniteScroll
=
new
InfiniteScroll
(
'
.container
'
,
{
// options
path
:
'
.pagination__next
'
,
// 设置加载下一页的链接的选择器
append
:
'
.row
'
,
// 设置加载的内容的选择器
history
:
false
,
// 设置是否保存历史记录
scrollThreshold
:
20
,
// 设置距离底部多少距离时加载下一页,默认为 "200"
hideNav
:
'
.pagination
'
,
status
:
'
.scroller-status
'
,
});
</script>
{% endblock %}
app/templates/school/pulltorefresh_btn.html
0 → 100644
浏览文件 @
ae29a78a
{% extends "base.html" %}
{% block script %}
{% endblock script %}
{% block content %}
<div
class=
"container"
>
{% 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>
<!-- status elements -->
<div
class=
"scroller-status"
style=
"display:none;padding-top: 20px;border-top: 1px solid #DDD;text-align: center;color: #777;"
>
<div
class=
"loader-ellips infinite-scroll-request"
>
<span
class=
"loader-ellips__dot"
></span>
<span
class=
"loader-ellips__dot"
></span>
<span
class=
"loader-ellips__dot"
></span>
<span
class=
"loader-ellips__dot"
></span>
</div>
<p
class=
"infinite-scroll-last"
>
数据到底了
</p>
<p
class=
"infinite-scroll-error"
>
加载失败
</p>
</div>
<p
class=
"text-center"
>
<button
class=
"btn btn-primary view-more-button"
>
加载更多
</button>
</p>
<!-- pagination has path -->
<p
class=
"pagination"
>
<a
class=
"pagination__next"
href=
"/ss/pr?page={{pagination.next_page}}"
>
下一页数据
</a>
</p>
<script
src=
"https://unpkg.com/infinite-scroll@3/dist/infinite-scroll.pkgd.min.js"
></script>
<script
type=
"text/javascript"
>
const
infiniteScroll
=
new
InfiniteScroll
(
'
.container
'
,
{
// options
path
:
'
.pagination__next
'
,
// 设置加载下一页的链接的选择器
append
:
'
.row
'
,
// 设置加载的内容的选择器
//history: false, // 设置是否保存历史记录
//scrollThreshold:20,// 设置距离底部多少距离时加载下一页,默认为 "200"
hideNav
:
'
.pagination
'
,
status
:
'
.scroller-status
'
,
button
:
'
.view-more-button
'
,
scrollThreshold
:
false
,
});
</script>
{% endblock %}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录