HTTP协议网络编程实战从零基础到项目落地的完整学习路径与常见问题解析

引言:HTTP协议的重要性与学习价值
HTTP(HyperText Transfer Protocol,超文本传输协议)是现代互联网的基石,它定义了客户端与服务器之间如何进行通信。从你浏览网页、使用移动应用,到调用RESTful API,HTTP协议无处不在。掌握HTTP协议及其网络编程技术,是成为一名优秀后端开发工程师、全栈工程师或DevOps工程师的必经之路。
本篇文章将为你提供一条从零基础到项目落地的完整学习路径,涵盖理论知识、实战代码、项目实践以及常见问题的深度解析。我们将使用Python作为主要演示语言,因为它语法简洁,非常适合快速验证HTTP概念。
第一部分:HTTP协议基础理论(零基础入门)
在编写代码之前,必须先理解HTTP协议的核心概念。这些概念是后续所有实战的基础。
1.1 HTTP协议是什么?
HTTP是一个
应用层协议
,基于TCP/IP通信协议来传输数据(通常是HTML文档、图片、查询结果等)。它是一个
无状态
的协议,这意味着服务器不会保留两个请求之间的任何关联数据。
1.2 HTTP请求与响应模型
HTTP通信总是由客户端发起请求,服务器返回响应。这个过程包含四个步骤:
建立连接 (TCP连接)
:客户端与服务器建立TCP连接。
发送请求
:客户端向服务器发送一个HTTP请求报文。
接收响应
:服务器处理请求后,返回一个HTTP响应报文。
关闭连接
:连接结束(在HTTP/1.1中默认开启Keep-Alive,连接会复用)。
1.3 HTTP请求报文详解
一个HTTP请求主要由三部分组成:
请求行 (Request Line)
、
请求头 (Headers)
和
请求体 (Body)
。
请求方法 (Method)
:
GET
:获取资源,参数在URL中。
POST
:提交数据,参数在请求体中。
PUT
:更新资源。
DELETE
:删除资源。
请求路径 (URL)
:资源的定位符。
协议版本
:如 HTTP/1.1, HTTP/2.0。
1.4 HTTP响应报文详解
响应报文同样由三部分组成:
状态行 (Status Line)
、
响应头 (Headers)
和
响应体 (Body)
。
状态码 (Status Code)
:
2xx
:成功(如 200 OK)。
3xx
:重定向(如 301 Moved Permanently)。
4xx
:客户端错误(如 404 Not Found, 403 Forbidden)。
5xx
:服务器错误(如 500 Internal Server Error)。
第二部分:Python网络编程实战(代码篇)
理论结合实践才能真正掌握。我们将使用Python标准库
http.client
和第三方库
requests
来深入理解HTTP编程。
2.1 使用标准库
http.client
进行底层操作
http.client
是Python内置的低级HTTP客户端,它能让你看到HTTP连接的细节。
场景
:向
httpbin.org
发送一个GET请求,并打印原始响应。
import http.client
import json

def low_level_http_request():
# 1. 建立连接
conn = http.client.HTTPConnection(“httpbin.org”, 80)

try:
# 2. 发送请求 (GET /get?name=alice HTTP/1.1)
conn.request(“GET”, “/get?name=alice”)

# 3. 获取响应
response = conn.getresponse()

# 打印状态行
print(f”Protocol: {response.version}”)
print(f”Status: {response.status} {response.reason}”)

# 打印响应头
print(“\n— Headers —“)
for key, value in response.getheaders():
print(f”{key}: {value}”)

# 打印响应体
body = response.read()
print(“\n— Body —“)
print(body.decode(‘utf-8’))

finally:
# 4. 关闭连接
conn.close()

if __name__ == “__main__”:
low_level_http_request()
代码解析
:
HTTPConnection
:创建一个到主机的TCP连接。
request()
:构建并发送HTTP请求行和头部。
getresponse()
:读取服务器返回的原始数据流。
注意
:这种方式需要手动管理连接(使用
finally
确保关闭),且处理重定向、编码等非常繁琐。
2.2 使用第三方库
requests
进行高级应用
requests
库被称为 “Python HTTP for Humans”,它封装了底层细节,是目前最流行的HTTP库。
场景
:发送POST请求,携带JSON数据,并处理响应。
import requests
import json

def advanced_http_request():
url = “https://httpbin.org/post”
headers = {
“Content-Type”: “application/json”,
“User-Agent”: “MyPythonApp/1.0”
}
payload = {
“username”: “zhangsan”,
“action”: “login”,
“timestamp”: 1678888888
}

try:
# 发送POST请求
response = requests.post(url, json=payload, headers=headers, timeout=5)

# 检查状态码 (自动处理重定向)
if response.status_code == 200:
# 自动解码JSON
data = response.json()
print(“请求成功!”)
print(f”服务器收到的JSON数据: {data[‘json’]}”)
print(f”Origin IP: {data[‘origin’]}”)
else:
print(f”请求失败,状态码: {response.status_code}”)

except requests.exceptions.Timeout:
print(“请求超时,请检查网络或服务器状态。”)
except requests.exceptions.RequestException as e:
print(f”发生错误: {e}”)

if __name__ == “__main__”:
advanced_http_request()
代码解析
:
requests.post
:一行代码完成了连接、发送、等待响应。
json=
参数:自动将Python字典序列化为JSON字符串,并设置正确的
Content-Type
。
response.json()
:自动将响应体中的JSON字符串反序列化为Python对象。
timeout
:防止程序因网络卡死而无限等待。
第三部分:构建简单的HTTP服务器(服务端编程)
理解服务端如何处理请求同样重要。我们可以使用Python内置的
http.server
模块快速搭建一个服务器。
3.1 简单的GET服务器
from http.server import HTTPServer, BaseHTTPRequestHandler
import json

class SimpleHandler(BaseHTTPRequestHandler):
# 处理GET请求
def do_GET(self):
# 1. 设置响应状态码 200
self.send_response(200)
# 2. 设置响应头
self.send_header(‘Content-type’, ‘application/json’)
self.end_headers()

# 3. 构建响应体
response_data = {
“message”: “Hello from Python Server!”,
“path”: self.path,
“method”: “GET”
}

# 4. 写入响应内容 (必须是bytes)
self.wfile.write(json.dumps(response_data).encode(‘utf-8’))

# 处理POST请求
def do_POST(self):
content_length = int(self.headers[‘Content-Length’])
post_data = self.rfile.read(content_length)

self.send_response(201)
self.send_header(‘Content-type’, ‘application/json’)
self.end_headers()

response_data = {
“status”: “received”,
“your_data”: post_data.decode(‘utf-8’)
}
self.wfile.write(json.dumps(response_data).encode(‘utf-8’))

def run_server():
server_address = (”, 8000)
httpd = HTTPServer(server_address, SimpleHandler)
print(“Server running on http://localhost:8000”)
httpd.serve_forever()

if __name__ == ‘__main__’:
run_server()
如何测试
:
运行上述代码。
在浏览器访问
http://localhost:8000
或使用curl:
curl http://localhost:8000/test
。
使用curl发送POST:
curl -X POST -d “data=123” http://localhost:8000
。
第四部分:项目落地 – 实现一个简易的Web爬虫
将HTTP知识应用到实际项目中,最经典的例子就是
网络爬虫
。我们将编写一个脚本,自动抓取网页标题。
4.1 项目需求
输入一个URL列表。
发送HTTP请求获取网页内容。
解析HTML提取
<br /> 标签。<br /> 处理可能出现的网络错误。<br /> 4.2 完整代码实现<br /> import requests<br /> from bs4 import BeautifulSoup<br /> from urllib.parse import urlparse<br /> import time</p> <p>class WebCrawler:<br /> def __init__(self):<br /> # 模拟浏览器头部,防止被反爬<br /> self.headers = {<br /> “User-Agent”: “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36”<br /> }</p> <p> def fetch_title(self, url):<br /> # 补全协议头<br /> if not url.startswith((‘http://’, ‘https://’)):<br /> url = ‘http://’ + url</p> <p> try:<br /> # 发送请求,设置超时<br /> response = requests.get(url, headers=self.headers, timeout=10)</p> <p> # 检查状态码<br /> if response.status_code == 200:<br /> # 使用BeautifulSoup解析HTML<br /> soup = BeautifulSoup(response.text, ‘html.parser’)<br /> title = soup.title.string if soup.title else “No Title”<br /> return {<br /> “url”: url,<br /> “title”: title.strip(),<br /> “status”: “Success”<br /> }<br /> else:<br /> return {<br /> “url”: url,<br /> “title”: None,<br /> “status”: f”HTTP {response.status_code}”<br /> }</p> <p> except requests.exceptions.RequestException as e:<br /> return {<br /> “url”: url,<br /> “title”: None,<br /> “status”: f”Error: {str(e)}”<br /> }</p> <p> def crawl_batch(self, url_list):<br /> results = []<br /> print(f”开始爬取 {len(url_list)} 个网址…”)</p> <p> for url in url_list:<br /> result = self.fetch_title(url)<br /> results.append(result)<br /> # 礼貌爬取,设置延时<br /> time.sleep(1) </p> <p> return results</p> <p>if __name__ == “__main__”:<br /> # 依赖安装: pip install requests beautifulsoup4</p> <p> crawler = WebCrawler()<br /> targets = [<br /> “www.baidu.com”,<br /> “www.google.com”,<br /> “http://www.python.org”,<br /> “invalid-url-example” # 故意写错一个测试错误处理<br /> ]</p> <p> data = crawler.crawl_batch(targets)</p> <p> print(“\n— 爬取结果 —“)<br /> for item in data:<br /> print(f”[{item[‘status’]}] {item[‘url’]} -> {item[‘title’]}”)<br /> 项目要点解析<br /> :<br /> User-Agent<br /> :很多服务器会拒绝没有User-Agent的请求,这属于HTTP头部的实战应用。<br /> 异常处理<br /> :网络是不稳定的,必须捕获<br /> RequestException<br /> 。<br /> HTML解析<br /> :HTTP返回的是文本(HTML),需要使用BeautifulSoup等库进行二次处理。<br /> 延时控制<br /> :<br /> time.sleep(1)<br /> 是为了遵守HTTP礼仪,避免对目标服务器造成DDoS攻击。<br /> 第五部分:常见问题解析 (FAQ)<br /> 在学习HTTP编程时,你一定会遇到以下问题。这里提供深度解析。<br /> 5.1 GET和POST的本质区别是什么?<br /> 很多初学者认为 “GET参数在URL,POST在Body” 是区别,但这只是表象。<br /> 语义上<br /> :GET用于获取资源(幂等),POST用于传输实体主体(通常改变服务器状态)。<br /> 安全性<br /> :GET参数在浏览器历史、服务器日志中可见,不适合传输敏感信息。<br /> 数据长度<br /> :URL长度有限制(不同浏览器约2k-8k),GET传输数据量小;POST理论上无限制。<br /> 缓存<br /> :GET请求会被浏览器主动缓存;POST默认不缓存。<br /> 5.2 什么是HTTP无状态?如何保持登录状态?<br /> HTTP无状态意味着服务器不知道你是谁,每次请求都是新的。<br /> 解决方案<br /> :<br /> Cookie/Session<br /> :服务器在第一次响应时设置<br /> Set-Cookie<br /> 头,浏览器后续请求会自动带上<br /> Cookie<br /> 。服务器通过Session ID识别用户。<br /> Token (JWT)<br /> :现代API常用方式。服务器返回一个加密的Token,客户端每次请求在<br /> Authorization<br /> 头中携带。<br /> 代码示例(保持会话)<br /> :<br /> import requests</p> <p># 使用 Session 对象自动处理 Cookie<br /> session = requests.Session()</p> <p># 第一次登录(假设需要POST)<br /> session.post(‘http://example.com/login’, data={‘user’: ‘admin’})</p> <p># 第二次请求(自动携带刚才的Cookie)<br /> response = session.get(‘http://example.com/dashboard’)<br /> 5.3 遇到 “Connection Reset” 或超时怎么办?<br /> 这通常是网络层或防火墙问题,而非HTTP代码逻辑错误。<br /> 检查目标服务器<br /> :目标是否宕机?<br /> 防火墙/代理<br /> :公司内网或云服务器通常有防火墙,需检查安全组规则(是否开放了80/443端口)。<br /> DNS解析<br /> :尝试使用<br /> ping<br /> 或<br /> nslookup<br /> 检查域名是否能解析。<br /> 代码层面<br /> :增加<br /> timeout<br /> 设置,使用重试机制(如<br /> requests<br /> 的<br /> Retry<br /> 配合<br /> Session<br /> )。<br /> 5.4 HTTPS是如何工作的?<br /> HTTPS = HTTP + SSL/TLS。<br /> 作用<br /> :加密传输内容,防止中间人攻击;验证服务器身份。<br /> 握手过程<br /> :<br /> 客户端发送请求(支持的加密套件)。<br /> 服务器返回证书(包含公钥)。<br /> 客户端验证证书(是否由受信任CA签发,域名是否匹配)。<br /> 生成会话密钥,后续通信使用对称加密。<br /> 编程注意<br /> :在Python中,<br /> requests<br /> 会自动验证HTTPS证书。如果访问自签名证书的内网服务,会报错<br /> SSLError<br /> 。此时可以设置<br /> verify=False<br /> (开发环境用,生产环境不推荐)。<br /> 5.5 HTTP/1.1 和 HTTP/2.0 有什么区别?<br /> 多路复用 (Multiplexing)<br /> :HTTP/1.1 如果想并发发送多个请求,需要建立多个TCP连接(队头阻塞问题)。HTTP/2.0 在一个TCP连接里并发处理多个请求响应,效率极高。<br /> 头部压缩<br /> :HTTP/2.0 使用HPACK算法压缩头部,减少传输体积。<br /> 二进制分帧<br /> :HTTP/1.1 是文本协议,HTTP/2.0 是二进制协议,解析更高效。<br /> 第六部分:进阶学习路径与总结<br /> 6.1 学习路径建议<br /> 巩固基础<br /> :熟练使用<br /> curl<br /> 命令行工具测试API,理解所有HTTP状态码和Header的含义。<br /> 深入框架<br /> :<br /> 客户端<br /> :深入学习<br /> requests<br /> 源码,或者学习<br /> aiohttp<br /> (异步HTTP库)。<br /> 服务端<br /> :学习一个Web框架(如 Flask, Django, FastAPI),理解路由、中间件、模板渲染。<br /> 网络抓包<br /> :使用<br /> Wireshark<br /> 或<br /> Fiddler<br /> 抓取HTTP包,亲眼看到TCP三次握手和HTTP报文的原始形态。<br /> 性能优化<br /> :学习HTTP缓存机制(Cache-Control, ETag)、CDN原理、负载均衡。<br /> 6.2 总结<br /> HTTP协议网络编程不仅仅是写代码发送请求,它是一套完整的互联网通信标准。从理解TCP/IP握手,到编写健壮的客户端代码,再到搭建高性能的服务端,每一步都需要扎实的理论支撑。<br /> 希望这篇指南能帮你打通从零基础到项目落地的任督二脉。记住,多写代码,多抓包,多分析错误,是掌握HTTP编程的唯一捷径。</p> </div> <div class="wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained" style="margin-top:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--50)"> <div class="wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained"> <div style="height:var(--wp--preset--spacing--40)" aria-hidden="true" class="wp-block-spacer"> </div> <hr class="wp-block-separator has-text-color has-contrast-3-color has-alpha-channel-opacity has-contrast-3-background-color has-background is-style-wide" style="margin-bottom:var(--wp--preset--spacing--40)"/> <nav class="wp-block-group is-content-justification-space-between is-nowrap is-layout-flex wp-container-core-group-is-layout-2b923ac6 wp-block-group-is-layout-flex" style="padding-top:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40)" aria-label="Posts"> <div class="post-navigation-link-previous wp-block-post-navigation-link"><span class="wp-block-post-navigation-link__arrow-previous is-arrow-arrow" aria-hidden="true">←</span><a href="https://ziliao.tiaomu.com/101463293/" rel="prev"><span class="post-navigation-link__label">Previous: </span> <span class="post-navigation-link__title">揭秘收银岗位:毕业论文摘要,揭秘行业秘密,探索职业发展路径</span></a></div> <div class="post-navigation-link-next wp-block-post-navigation-link"><a href="https://ziliao.tiaomu.com/101463295/" rel="next"><span class="post-navigation-link__label">Next: </span> <span class="post-navigation-link__title">Linux系统中控权限管理实战指南如何安全高效地配置sudoers文件与PAM认证避免常见配置错误与安全风险</span></a><span class="wp-block-post-navigation-link__arrow-next is-arrow-arrow" aria-hidden="true">→</span></div> </nav> </div> </div> </main> <footer class="wp-block-template-part"> <div class="wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained" style="padding-top:var(--wp--preset--spacing--50);padding-bottom:var(--wp--preset--spacing--50)"> <div class="wp-block-columns alignwide is-layout-flex wp-container-core-columns-is-layout-3a88641f wp-block-columns-is-layout-flex"> <div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:30%"> <div class="wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-831b2db5 wp-block-group-is-layout-flex"> <p class="wp-block-site-title has-medium-font-size"><a href="https://ziliao.tiaomu.com" target="_self" rel="home">资料库 – 中文知识库</a></p> </div> </div> <div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:20%"> </div> <div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:50%"> <div class="wp-block-group is-content-justification-space-between is-layout-flex wp-container-core-group-is-layout-cf54d0a6 wp-block-group-is-layout-flex"> <div class="wp-block-group is-vertical is-content-justification-stretch is-layout-flex wp-container-core-group-is-layout-d8dce8eb wp-block-group-is-layout-flex"> <h2 class="wp-block-heading has-medium-font-size has-body-font-family" style="font-style:normal;font-weight:600">About</h2> <div class="wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-bce0c455 wp-block-group-is-layout-flex"> <nav style="font-style:normal;font-weight:400" class="has-small-font-size is-vertical wp-block-navigation is-layout-flex wp-container-core-navigation-is-layout-bce0c455 wp-block-navigation-is-layout-flex" aria-label="About"><ul style="font-style:normal;font-weight:400" class="wp-block-navigation__container has-small-font-size is-vertical wp-block-navigation" aria-label="About"><li class="wp-block-navigation-item wp-block-navigation-link"><a class="wp-block-navigation-item__content" href="#"><span class="wp-block-navigation-item__label">Team</span></a></li><li class="wp-block-navigation-item wp-block-navigation-link"><a class="wp-block-navigation-item__content" href="#"><span class="wp-block-navigation-item__label">History</span></a></li><li class="wp-block-navigation-item wp-block-navigation-link"><a class="wp-block-navigation-item__content" href="#"><span class="wp-block-navigation-item__label">Careers</span></a></li></ul></nav> </div> </div> <div class="wp-block-group is-vertical is-content-justification-stretch is-layout-flex wp-container-core-group-is-layout-d8dce8eb wp-block-group-is-layout-flex"> <h2 class="wp-block-heading has-medium-font-size has-body-font-family" style="font-style:normal;font-weight:600">Privacy</h2> <div class="wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-bce0c455 wp-block-group-is-layout-flex"> <nav style="font-style:normal;font-weight:400" class="has-small-font-size is-vertical wp-block-navigation is-layout-flex wp-container-core-navigation-is-layout-bce0c455 wp-block-navigation-is-layout-flex" aria-label="Privacy"><ul style="font-style:normal;font-weight:400" class="wp-block-navigation__container has-small-font-size is-vertical wp-block-navigation" aria-label="Privacy"><li class="wp-block-navigation-item wp-block-navigation-link"><a class="wp-block-navigation-item__content" href="#"><span class="wp-block-navigation-item__label">Privacy Policy</span></a></li><li class="wp-block-navigation-item wp-block-navigation-link"><a class="wp-block-navigation-item__content" href="#"><span class="wp-block-navigation-item__label">Terms and Conditions</span></a></li><li class="wp-block-navigation-item wp-block-navigation-link"><a class="wp-block-navigation-item__content" href="#"><span class="wp-block-navigation-item__label">Contact Us</span></a></li></ul></nav> </div> </div> <div class="wp-block-group is-vertical is-content-justification-stretch is-layout-flex wp-container-core-group-is-layout-d8dce8eb wp-block-group-is-layout-flex"> <h2 class="wp-block-heading has-medium-font-size has-body-font-family" style="font-style:normal;font-weight:600">Social</h2> <div class="wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-bce0c455 wp-block-group-is-layout-flex"> <nav style="font-style:normal;font-weight:400" class="has-small-font-size is-vertical wp-block-navigation is-layout-flex wp-container-core-navigation-is-layout-bce0c455 wp-block-navigation-is-layout-flex" aria-label="Social Media"><ul style="font-style:normal;font-weight:400" class="wp-block-navigation__container has-small-font-size is-vertical wp-block-navigation" aria-label="Social Media"><li class="wp-block-navigation-item wp-block-navigation-link"><a class="wp-block-navigation-item__content" href="#"><span class="wp-block-navigation-item__label">Facebook</span></a></li><li class="wp-block-navigation-item wp-block-navigation-link"><a class="wp-block-navigation-item__content" href="#"><span class="wp-block-navigation-item__label">Instagram</span></a></li><li class="wp-block-navigation-item wp-block-navigation-link"><a class="wp-block-navigation-item__content" href="#"><span class="wp-block-navigation-item__label">Twitter/X</span></a></li></ul></nav> </div> </div> </div> </div> </div> <div class="wp-block-group alignwide is-layout-flow wp-block-group-is-layout-flow" style="padding-top:var(--wp--preset--spacing--50);padding-bottom:0"> <p class="has-contrast-2-color has-text-color has-link-color has-small-font-size wp-elements-1 wp-block-paragraph"> Designed with <a href="https://wordpress.org" rel="nofollow">WordPress</a> </p> </div> </div> </footer> </div> <script type="speculationrules"> {"prefetch":[{"source":"document","where":{"and":[{"href_matches":"/*"},{"not":{"href_matches":["/wp-*.php","/wp-admin/*","/wp-content/uploads/*","/wp-content/*","/wp-content/plugins/*","/wp-content/themes/twentytwentyfour/*","/*\\?(.+)"]}},{"not":{"selector_matches":"a[rel~=\"nofollow\"]"}},{"not":{"selector_matches":".no-prefetch, .no-prefetch a"}}]},"eagerness":"conservative"}]} </script> <script data-wp-router-options="{"loadOnClientNavigation":true}" fetchpriority="low" id="@wordpress/block-library/navigation/view-js-module" src="https://ziliao.tiaomu.com/wp-includes/js/dist/script-modules/block-library/navigation/view.min.js?ver=1bf28ded04f9f188bdcb" type="module"></script> <script id="wp-emoji-settings" type="application/json"> {"baseUrl":"https://s.w.org/images/core/emoji/17.0.2/72x72/","ext":".png","svgUrl":"https://s.w.org/images/core/emoji/17.0.2/svg/","svgExt":".svg","source":{"concatemoji":"https://ziliao.tiaomu.com/wp-includes/js/wp-emoji-release.min.js?ver=7.1.5"}} </script> <script type="module"> /*! This file is auto-generated */ var e="script#wp-emoji-settings",t=document.querySelector(e);if(!(t instanceof HTMLScriptElement))throw new Error("Element missing: "+e);const r=JSON.parse(t.text),s=(window._wpemojiSettings=r,"wpEmojiSettingsSupports"),o=["flag","emoji"];function i(e){try{var t={supportTests:e,timestamp:(new Date).valueOf()};sessionStorage.setItem(s,JSON.stringify(t))}catch(e){}}function c(e,t,n){e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillText(t,0,0);t=new Uint32Array(e.getImageData(0,0,e.canvas.width,e.canvas.height).data);e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillText(n,0,0);const r=new Uint32Array(e.getImageData(0,0,e.canvas.width,e.canvas.height).data);return t.every((e,t)=>e===r[t])}function p(e,t){e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillText(t,0,0);var n=e.getImageData(16,16,1,1);for(let e=0;e<n.data.length;e++)if(0!==n.data[e])return!1;return!0}function u(e,t,n,r){switch(t){case"flag":return n(e,"\ud83c\udff3\ufe0f\u200d\u26a7\ufe0f","\ud83c\udff3\ufe0f\u200b\u26a7\ufe0f")?!1:!n(e,"\ud83c\udde8\ud83c\uddf6","\ud83c\udde8\u200b\ud83c\uddf6")&&!n(e,"\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f","\ud83c\udff4\u200b\udb40\udc67\u200b\udb40\udc62\u200b\udb40\udc65\u200b\udb40\udc6e\u200b\udb40\udc67\u200b\udb40\udc7f");case"emoji":return!r(e,"\ud83e\u1fac8")}return!1}function f(e,t,n,r){let a;const s=(a="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?new OffscreenCanvas(300,150):document.createElement("canvas")).getContext("2d",{willReadFrequently:!0}),o=(s.textBaseline="top",s.font="600 32px Arial",{});return e.forEach(e=>{o[e]=t(s,e,n,r)}),o}function a(e){var t=document.createElement("script");t.src=e,t.defer=!0,document.head.appendChild(t)}r.supports={everything:!0,everythingExceptFlag:!0},new Promise(t=>{let n=function(){try{var e=JSON.parse(sessionStorage.getItem(s));if("object"==typeof e&&"number"==typeof e.timestamp&&(new Date).valueOf()<e.timestamp+604800&&"object"==typeof e.supportTests)return e.supportTests}catch(e){}return null}();if(!n){if("undefined"!=typeof Worker&&"undefined"!=typeof OffscreenCanvas&&"undefined"!=typeof URL&&URL.createObjectURL&&"undefined"!=typeof Blob)try{var e="postMessage("+f.toString()+"("+[JSON.stringify(o),u.toString(),c.toString(),p.toString()].join(",")+"));",r=new Blob([e],{type:"text/javascript"});const a=new Worker(URL.createObjectURL(r),{name:"wpTestEmojiSupports"});return void(a.onmessage=e=>{i(n=e.data),a.terminate(),t(n)})}catch(e){}i(n=f(o,u,c,p))}t(n)}).then(e=>{for(const n in e)r.supports[n]=e[n],r.supports.everything=r.supports.everything&&r.supports[n],"flag"!==n&&(r.supports.everythingExceptFlag=r.supports.everythingExceptFlag&&r.supports[n]);var t;r.supports.everythingExceptFlag=r.supports.everythingExceptFlag&&!r.supports.flag,r.supports.everything||((t=r.source||{}).concatemoji?a(t.concatemoji):t.wpemoji&&t.twemoji&&(a(t.twemoji),a(t.wpemoji)))}); //# sourceURL=https://ziliao.tiaomu.com/wp-includes/js/wp-emoji-loader.min.js </script> <noscript><link rel="stylesheet" href="https://ziliao.tiaomu.com/wp-content/themes/abiz/assets/css/all.min.css?ver=6.5.1"></noscript> </body> </html>