简单的html post,POST其实很简单 17 HTML简单入门1:网页的基本结构

要进行post抓包必然少不了跟html页面打交道。

这节课开始我们要花几节课的时间来大致讲一点html的基础入门知识。请注意是大致的讲讲,为我们之后分析网页源码做准备的,所以不会讲的特别细致。学完这几课,你可能无法自己写出一个精美的html页面,但是对于之后我们分析网页源码来说,应该是足够了。

如果你是前端开发牛人的话,那这几节课你可以跳过了。

我们重点讲两个问题:

1.要怎么查看网页源码?

方法有很多,在网页上右键,选择“查看源文件”或“查看源码”(不同浏览器可能不一样),以搜狗浏览器为例,叫做查看源文件,而在搜狗浏览器中也可以通过在原有网址前面加上“view-source:”来访问实现查看源码。如图为一个小学生作文网站的源码:

webp

我们重点讲两个问题:

2.一个最简单的html网页的结构是怎样的?

网页由标签组成, &>*?>,问号部分是标签的名字,标签一般成对出现,个别标签可能单个出现,但通常都少不了/这个符号的闭合。&符号部分可能有可能没有,会罗列这个标签的一些属性。*星号部分是标签包含的内容,这些内容在这个标签和这些属性下面生效起作用。以下是一个最简单的网页源码:

内容

课后作业:

自己找一些网页,查看它的源代码,再对比一下前台展示出来的页面,你有什么发现

我相信,你一定会爱上它的!

以下是我们的视频教程:

在线观看:

内容已经隐藏,请注册为本站会员后查看

高清源文件下载:

内容已经隐藏,请注册为本站会员后查看

感谢大家的收看,我们下期再见!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要设计一个完整的图书管理系统需要多个页面和功能,这里提供一个简单的图书查询和借阅功能的网页示例代码。 首先需要安装Flask框架和MySQL数据库驱动程序,可以使用以下命令安装: ``` pip install Flask pip install mysql-connector-python ``` 然后创建一个名为`app.py`的Python文件,输入以下代码: ```python from flask import Flask, render_template, request, redirect import mysql.connector app = Flask(__name__) # 连接MySQL数据库 mydb = mysql.connector.connect( host="localhost", user="root", password="password", database="library" ) # 首页,显示所有图书信息 @app.route('/') def index(): mycursor = mydb.cursor() mycursor.execute("SELECT * FROM books") books = mycursor.fetchall() return render_template('index.html', books=books) # 查询图书 @app.route('/search', methods=['POST']) def search(): keyword = request.form.get('keyword') mycursor = mydb.cursor() mycursor.execute("SELECT * FROM books WHERE title LIKE %s OR author LIKE %s", ('%'+keyword+'%', '%'+keyword+'%')) books = mycursor.fetchall() return render_template('search.html', books=books) # 借阅图书 @app.route('/borrow', methods=['POST']) def borrow(): book_id = request.form.get('book_id') mycursor = mydb.cursor() mycursor.execute("UPDATE books SET quantity = quantity - 1 WHERE id = %s AND quantity > 0", (book_id,)) mydb.commit() return redirect('/') if __name__ == '__main__': app.run(debug=True) ``` 这段代码定义了三个路由: - `/`:首页,显示所有图书信息 - `/search`:查询图书 - `/borrow`:借阅图书 还需要创建两个HTML模板文件,分别为`templates/index.html`和`templates/search.html`,代码如下: `index.html`: ```html <!DOCTYPE html> <html> <head> <title>图书馆</title> </head> <body> <h1>图书馆</h1> <form action="/search" method="POST"> <input type="text" name="keyword" placeholder="请输入关键词"> <button type="submit">搜索</button> </form> <table> <tr> <th>ID</th> <th>书名</th> <th>作者</th> <th>数量</th> <th>操作</th> </tr> {% for book in books %} <tr> <td>{{ book[0] }}</td> <td>{{ book[1] }}</td> <td>{{ book[2] }}</td> <td>{{ book[3] }}</td> <td> <form action="/borrow" method="POST"> <input type="hidden" name="book_id" value="{{ book[0] }}"> {% if book[3] > 0 %} <button type="submit">借阅</button> {% else %} <button type="button" disabled>已借完</button> {% endif %} </form> </td> </tr> {% endfor %} </table> </body> </html> ``` `search.html`: ```html <!DOCTYPE html> <html> <head> <title>图书馆 - 搜索结果</title> </head> <body> <h1>图书馆 - 搜索结果</h1> <form action="/search" method="POST"> <input type="text" name="keyword" placeholder="请输入关键词" value="{{ request.form.get('keyword') }}"> <button type="submit">搜索</button> </form> <table> <tr> <th>ID</th> <th>书名</th> <th>作者</th> <th>数量</th> <th>操作</th> </tr> {% for book in books %} <tr> <td>{{ book[0] }}</td> <td>{{ book[1] }}</td> <td>{{ book[2] }}</td> <td>{{ book[3] }}</td> <td> <form action="/borrow" method="POST"> <input type="hidden" name="book_id" value="{{ book[0] }}"> {% if book[3] > 0 %} <button type="submit">借阅</button> {% else %} <button type="button" disabled>已借完</button> {% endif %} </form> </td> </tr> {% endfor %} </table> </body> </html> ``` 这两个模板文件分别展示了所有图书信息和搜索结果,并提供了借阅按钮。可以根据需要修改模板文件的样式和布局。 最后还需要创建MySQL数据库和`books`表,代码如下: ``` CREATE DATABASE library; USE library; CREATE TABLE books ( id INT AUTO_INCREMENT PRIMARY KEY, title VARCHAR(255) NOT NULL, author VARCHAR(255) NOT NULL, quantity INT NOT NULL ); INSERT INTO books (title, author, quantity) VALUES ('Python编程从入门到实践', 'Eric Matthes', 5); INSERT INTO books (title, author, quantity) VALUES ('流畅的Python', 'Luciano Ramalho', 3); INSERT INTO books (title, author, quantity) VALUES ('Python核心编程', 'Wesley Chun', 2); ``` 以上代码创建了一个名为`library`的数据库,并在其中创建了一个名为`books`的表,并插入了三条图书信息。可以根据需要修改数据库和表的结构。 完成以上步骤后,运行`app.py`文件,即可在浏览器中访问图书管理系统的网页界面。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值