Azus

Never be a sad song with nothing to say.

0%

HTTP解析

阅读 《图解HTML》笔记。
使用request/bs4进行爬虫等项目时遇到的http协议相关问题,做一个记录。

TCP/IP

The Internet protocol suite, commonly known as TCP/IP, is the set of communications protocols used in the Internet and similar computer networks. The current foundational protocols in the suite are the Transmission Control Protocol (TCP) and the Internet Protocol (IP).

通常网络建立在TCP/IP协议族上。HTTP属于内部子集

协议:不同硬件操作系统之间通信的规则

TCP/IP层级:

TCP/IP协议族层次化为四级:

  1. 应用层:e.g.: FTP, DNS, HTTP
  2. 传输层: e.g.: TCP(Transimission Control Protocal), UDP(User Data Protocal)
  3. 网络层:
  4. 链路层(网络接口层)所有硬件范畴

在层级中传输数据时,每经过一层会被打上一个首部信息。(接收端没过一层消去)
这种把数据包装起来的做法称为封装(encapsulate)

与HTTP密切相关的协议

负责传输IP(Internet Protocal)

位于网络层。(不要与IP地址搞混,IP是协议名称)几乎所有使用网络的系统

IP吧各种数据包传送给对方。IP地址和MAC(Media Access Control Address)

AEP协议 (Address Resolution Protocal):根据IP地址反查MAC地址

Routing(路由选择)

确保可靠性的TCP协议

在传输层,提供可靠的字节流服务(Byte Stream Service)

TCP易于传输:字节流服务(Byte Stream Service): 大型数据分割为文段(segment)为单位的数据包。

TCP确保传输:三次握手:

1
2
3
>>>Sender: flag_SYN(synchronize)
>Receiver: flag_SYN, flag_ACK(acknowlegement)
>>>Sender: flag_ACK

域名解析DNS(Domain Name System)

与HTTP一样,运行在应用层。提供域名到IP之间的解析服务

URL & URI

URL(Uniform Resources Locator) 是URI(Uniform Resources Identifier)的子集。 总的来说,URL使用地址形式(哪个服务器上的哪个资源)指定特定资源。
Zhihu:URI&URL

Uniform: 以统一的格式方便处理各种资源(ftp:, http:)

URL格式

1
2
3
4
5
6
7
8
9
http://user:pass@www.example.jp:80/dir/index.htm?uid=1#ch1

'http://' 协议方案名
'user:pass' 登陆信息(opt)
'www.exm.jp' 服务器地址,可以是DNS可以解析的域名或192.168.1.1的ipv4或[0:0:0:0:0:0:0:1]这样用方括号的ipv6
'80'服务器端口
'/dir/index.htm'带层次的文件路径
'查询字符串'针对路境内的资源,可以使用查询字符串传入
'ch1'片段标识符,可以标记出已获取资源中的字资源(进一步定位)