HTTP:
超文本傳輸協定(英文:HyperText Transfer Protocol,縮寫:HTTP)是一種用於分佈式、協作式和超媒體信息系統的應用層協議。 HTTP是全球資訊網的數據通信的基礎。
W3C 简介 MDN 简介
HTML 所有标签列表
常见标签:a、form、input、button、h1、p、ul、ol、small、strong、div、span、kbd、video、audio、svg
空标签
空标签就是不用加闭标签的标签如不需要</xxx>
when the span is present
什么是可替换标签
CSS 里,可替换元素(replaced element)的展现不是由CSS来控制的。这些元素是一类 外观渲染独立于CSS的 外部对象。 典型的可替换元素有、
请求的格式
1 动词 路径 协议/版本2 Key1: value12 Key2: value22 Key3: value32 Content-Type: application/x-www-form-urlencoded2 Host: www.baidu.com2 User-Agent: curl/7.54.03 4 要上传的数据复制代码
GET / HTTP/1.1Host: www.baidu.comUser-Agent: curl/7.54.0Accept: */*复制代码
POST / HTTP/1.1Host: www.baidu.comUser-Agent: curl/7.54.0Accept: */*复制代码
响应的格式
1 协议/版本号 状态码 状态解释2 Key1: value12 Key2: value22 Content-Length: 179312 Content-Type: text/html34 要下载的内容复制代码
HTTP/1.1 200 OKAccept-Ranges: bytesCache-Control: private, no-cache, no-store, proxy-revalidate, no-transformConnection: Keep-AliveContent-Length: 2443Content-Type: text/htmlDate: Tue, 10 Oct 2017 09:14:05 GMTEtag: "5886041d-98b"Last-Modified: Mon, 23 Jan 2017 13:24:45 GMTPragma: no-cacheServer: bfe/1.0.8.18Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/ 省略了……复制代码
如何用Chrome开发者工具查看 HTTP 响应内容
- 打开Network
- 刷新网址
- 选中第一个响应
- 查看Headers里的Response Headers点view source可以看到响应的前两部分,Request >Headers点view source可以看到请求
- 查看Response你可以看到响应的第四部分
DNS 通过域名找IP地址
两个命令: nslookup www.baidu.com
ping www.baidu.com
因为有时候电信会给你假IP,为什么?,我不知道?~ 修改hosts文件在终端:
vi ~/etc/hosts
在里面添加一行xxx.xxx.xxx.xxx baidu.com
保存退出,再ping baidu.com,返回的就会是xxx.xxx.xxx.xxx了,这样就绕过了DNS
HTTP 请求包括哪些部分
状态码概要,是服务器对浏览器说的话 1xx 不常用 2xx 表示成功 3xx 表示滚吧 4xx 表示你丫错了 5xx 表示好吧,我错了 xxx (给人看的信息) ?
?讲人话?
2xx成功
200 ok
请求已成功,
204 No Content
服务器接收到的请求,但是没东西给回你
206 Partial Content
服务器已经成功处理了部分GET请求。类似于FlashGet或者迅雷这类的HTTP 下载工具都是使用此类响应实现断点续传或者将一个大文档分解为多个下载段同时下载。
3xx重定向
301 Moved Permanently
资源已永久永久永久移动到新位置
302 Found
网站临时性重定向,暂时不能访问如:备案、升级等等...区别
307
客户端收到的新的 URI,不是原始请求资源的替代引用。
304 Not Modified
懒得和你说多一遍,你遇到的问题同上(上一次放回一样)表示资源未被修改
307 Temporary Redirect
可以理解为一个临时的重定向,与302重定向有所区别的地方在于,收到307响应码后,客户端应保持请求方法不变向新的地址发出请求。
4xx客户端错误
400 Bad Request
由于明显的客户端错误(例如,格式错误的请求语法,太大的大小,无效的请求消息或欺骗性路由请求),服务器不能或不会处理该请求。
401 Unauthorized
要知道你是何许人也~~即用户没有必要的凭据。该状态码表示当前请求需要用户验证。
404 Not Found
服务器找不到请求的网页。这个不知道回去卖红薯~~?????
5xx服务器错误
服务器已经理解请求,但是拒绝执行它。让你死的明明白白?
500 Internal Server Error
通用错误消息,服务器遇到了一个未曾预料的状况,导致了它无法完成对请求的处理。没有给出具体错误信息。
503 Service Unavailable
服务器要么休息♨️要么炸了?,都是暂时的~如果知道什么时候恢复会返回包含一个Retry-After头用以标明这个延迟时间 如何用Chrome开发者工具查看 HTTP 响应内容
?如何使用 curl 命令?
curl -s -v -H "Frank: xxx" -- "https://www.baidu.com"复制代码
transfer a URL复制代码
-s, - 沉默 无声或安静模式。不要显示进度表或错误消息。静音。
-s, --silent Silent or quiet mode. Don't show progress meter or error messages. Makes Curl mute.复制代码
-v,--verbose 显示请求与响应,啰嗦模式~
-v, --verbose Makes the fetching more verbose/talkative. Mostly useful for debugging. A line starting with '>' means "header data" sent by curl, '<' means "header data" received by curl that is hidden in normal cases, and a line starting with '*' means additional info provided by curl.复制代码
-H,--header
添加一个响应头,<header>
里面加东西 -H, --header(HTTP) Extra header to use when getting a web page. You may specify any number of extra headers. Note that if you should add a custom header that has the same name as one of the internal ones curl would use, your externally set header will be used instead of the internal one. This allows you to make even trickier stuff than curl would normally do. You should not replace internally set headers without knowing perfectly well what you're doing. Remove an internal header by giving a replacement without content on the right side of the colon, as in: -H "Host:". curl will make sure that each header you add/replace is sent with the proper end-of-line marker, you should thus not add that as a part of the header content: do not add newlines or carriage returns, they will only mess things up for you. See also the -A, --user-agent and -e, --referer options. This option can be used multiple times to add/replace/remove multiple headers.复制代码