Backend-test/README.md

50 lines
2.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[涉及到的一些内容](./tech.md)
## 简述
你需要提交一个使用 `Python` 制作的后端程序,包含以下功能
+ 连接到本地的 `SQLite` 数据库来管理数据
+ 通过 `Flask` 框架搭建一个 `HTTP` 服务器来处理 `GET` 请求
+ 通过简单的爬虫来获取指定网站的数据
+ 将整个代码库提交到 `git` 托管网站上(⚠请创建私有代码库以确保代码安全)
+ (可选) 用面向对象的思想拆分各个模块来提高代码的可读性
+ (可选) 提供筛选查找功能(详见下方的 3.
## 详情
1. 写一个爬虫来爬取教务处首页([http://dean.xjtu.edu.cn/jxxx/xytz.htm](http://dean.xjtu.edu.cn/jxxx/xytz.htm) 学业通知栏目中的通知列表,并将其存储在 本地的 `SQLite` 数据库 `data.db`
![1694848053023.png](https://picture-1300689095.file.myqcloud.com/2023/09/16/65055436b7dff.png)
2. 使用 `Flask` 框架展示爬取到的数据,在`GET /` 时,通过 `render_template` 将**指定格式**的数据传递到模板 `index.html` 中展示
3. (可选拓展)使用 `Flask` 框架提供筛选查找功能,在 `POST /data` 的时候,取出请求中传递的 `date`,并通过 `date` 字段来筛选数据,将筛选后的数据传递到模板 `index.html` 中展示
## 更多说明
1. **指定格式的**数据
```
[
{
"title": "关于做好推荐2024年优秀应届本科毕业生免试攻读研究生工作的通知",
# title 表示通知的标题
"date": "2023-09-15",
# date 表示通知发表的日期
"link": "/info/1013/12030.htm",
# link 表示点击后跳转的链接
},
...
# 很多个相同类型的数据
]
```
2. 数据库参考格式:
| id | title | date | link |
| --- | ------------------------------------------------------------ | ---------- | -------------------- |
| 1 | 关于做好推荐2024年优秀应届本科毕业生免试攻读研究生工作的通知 | 2023-09-15 | /info/1013/12030.htm |
| 2 | ... | ... | ... |
3. 文件夹 `ref` 中包含了一些参考代码,你可以参考其中的代码来完成任务
4. 用于渲染数据的模板 `index.html``ref/templates` 文件夹中,简单修改后即可使用
5. 截止时间为 2023.09.23 23:59:59