网络域允许追踪页面的网络活动。它暴露了关于http、文件、数据及其他请求和响应的信息,包括它们的头部、主体、时间等。
EN
Network domain allows tracking network activities of the page. It exposes information about http, file, data and other requests and responses, their headers, bodies, timing, etc.
✅️️ Methods
🔨Network.clearBrowserCache
清除浏览器缓存。
EN
🔨Network.clearBrowserCookies
清除浏览器Cookie。
EN
🔨Network.deleteCookies
删除具有匹配名称和URL或域名/路径/分区键对的浏览器Cookie。
EN
Deletes browser cookies with matching name and url or domain/path/partitionKey pair.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| name | ✔️ | | string | 要移除的Cookie的名称。 | ENName of the cookies to remove. |
| url | | | string | 如果指定,将删除所有具有给 定名称且域名和路径与提供的URL匹配的cookie。 | ENIf specified, deletes all the cookies with the given name where domain and path match provided URL. |
| domain | | | string | 如果指定,仅删除具有确切域名的Cookie。 | ENIf specified, deletes only cookies with the exact domain. |
| path | | | string | 如果指定,仅删除路径完全匹配的''和``内的内容的cookie。 | ENIf specified, deletes only cookies with the exact path. |
| partitionKey | | 🧪 | CookiePartitionKey | 如果指定,仅删除具有给定名称和分区键的Cookie,其中所有分区键属性均与Cookie分区键属性匹配。 | ENIf specified, deletes only cookies with the the given name and partitionKey where all partition key attributes match the cookie partition key attribute. |
🔨Network.disable
禁用网络跟踪,防止网络事件被发送到客户端。
EN
Disables network tracking, prevents network events from being sent to the client.
🔨Network.enable
启用网络追踪功能,网络事件现在将发送给客户端。
EN
Enables network tracking, network events will now be delivered to the client.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| maxTotalBufferSize | | 🧪 | integer | 保留网络负载(XHR等)时使用的缓冲区大小(以字节为单位)。这是此DevTools会话将收集的最大字节数。 | ENBuffer size in bytes to use when preserving network payloads (XHRs, etc). This is the maximum number of bytes that will be collected by this DevTools session. |
| maxResourceBufferSize | | 🧪 | integer | 每个资源的缓冲区大小(以字节为单位),用于保存网络负载(XHR等)。 | ENPer-resource buffer size in bytes to use when preserving network payloads (XHRs, etc). |
| maxPostDataSize | | | integer | 请求将发送通知中包含的最长帖子正文大小(以字节为单位) | ENLongest post body size (in bytes) that would be included in requestWillBeSent notification |
| reportDirectSocketTraffic | | 🧪 | boolean | 是否应报告DirectSocket分块发送/接收事件。 | ENWhether DirectSocket chunk send/receive events should be reported. |
| enableDurableMessages | | 🧪 | boolean | 启用将响应体存储在渲染器外部,以便这些响应体能在跨进程导航中保留。需要设置maxTotalBufferSize。当前默认值为false。由于在发出Runtime.runIfWaitingForDebugger之前等待Network.enable可能导致死锁,该字段正在被弃用,转而支持专用的configureDurableMessages命令。 | ENEnable storing response bodies outside of renderer, so that these survive a cross-process navigation. Requires maxTotalBufferSize to be set. Currently defaults to false. This field is being deprecated in favor of the dedicated configureDurableMessages command, due to the possibility of deadlocks when awaiting Network.enable before issuing Runtime.runIfWaitingForDebugger. |
🔨Network.getCookies
返回当前URL的所有浏览器Cookie。根据后端支持情况,将在cookies字段中返回详细的Cookie信息。
EN
Returns all browser cookies for the current URL. Depending on the backend support, will return detailed cookie information in the cookies field.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| urls | | | array[string] | 将获取适用Cookie的URL列表。如果未指定,则假定设置为包含页面及其所有子框架URL的列表。 | ENThe list of URLs for which applicable cookies will be fetched. If not specified, it's assumed to be set to the list containing the URLs of the page and all of its subframes. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| cookies | array[Cookie] | Cookie对象数组。 | ENArray of cookie objects. |
🔨Network.getRequestPostData
返回随请求发送的发布数据。当请求未附带数据时,将返回错误。
EN
Returns post data sent with the request. Returns an error when no data was sent with the request.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| requestId | ✔️ | | RequestId | 获取内容的网络请求标识符。 | ENIdentifier of the network request to get content for. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| postData | string | 请求体字符串,省略多部分请求中的文件 | ENRequest body string, omitting files from multipart requests |
| base64Encoded | boolean | 是的,如果内容是以base64格式发送的。 | ENTrue, if content was sent as base64. |
🔨Network.getResponseBody
返回为给定请求提供的内容。
EN
Returns content served for the given request.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| requestId | ✔️ | | RequestId | 获取内容的网络请求标识符。 | ENIdentifier of the network request to get content for. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| body | string | 响应正文。 | ENResponse body. |
| base64Encoded | boolean | 是的,如果内容是以 base64 格式发送的。 | ENTrue, if content was sent as base64. |
🔨Network.setBypassServiceWorker
切换是否忽略每个请求的服务工作者。
EN
Toggles ignoring of service worker for each request.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| bypass | ✔️ | | boolean | 绕过服务工作者并从网络加载。 | ENBypass service worker and load from network. |
🔨Network.setCacheDisabled
切换是否忽略每个请求的缓存。如果为true,则不会使用缓存。
EN
Toggles ignoring cache for each request. If true, cache will not be used.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| cacheDisabled | ✔️ | | boolean | 缓存禁用状态。 | ENCache disabled state. |
🔨Network.setCookie
使用给定的cookie数据设置一个cookie;如果存在等效的cookie,可能会覆盖它们。
EN
Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| name | ✔️ | | string | Cookie name. | ENCookie name. |
| value | ✔️ | | string | Cookie值。 | ENCookie value. |
| url | | | string | 与cookie设置相关联的请求URI。该值会影响所创建cookie的默认域名、路径、源端口和源方案值。 | ENThe request-URI to associate with the setting of the cookie. This value can affect the default domain, path, source port, and source scheme values of the created cookie. |
| domain | | | string | Cookie domain. | ENCookie domain. |
| path | | | string | Cookie 路径。 | ENCookie path. |
| secure | | | boolean | 如果 cookie 是安全的,则为 True。 | ENTrue if cookie is secure. |
| httpOnly | | | boolean | 如果 cookie 是 http-only,则为 True。 | ENTrue if cookie is http-only. |
| sameSite | | | CookieSameSite | Cookie SameSite 类型。 | ENCookie SameSite type. |
| expires | | | TimeSinceEpoch | Cookie 过期日期,如果未设置则为会话 Cookie | ENCookie expiration date, session cookie if not set |
| priority | | 🧪 | CookiePriority | Cookie 优先级类型。 | ENCookie Priority type. |
| sourceScheme | | 🧪 | CookieSourceScheme | Cookie 来源方案类型。 | ENCookie source scheme type. |
| sourcePort | | 🧪 | integer | Cookie 源端口。有效值为 {-1, [1, 65535]},-1 表示未指定端口。未指定的端口值允许协议客户端模拟旧版 Cookie 的端口作用域。这是一个临时功能,未来将被移除。 | ENCookie source port. Valid values are {-1, [1, 65535]}, -1 indicates an unspecified port. An unspecified port value allows protocol clients to emulate legacy cookie scope for the port. This is a temporary ability and it will be removed in the future. |
| partitionKey | | 🧪 | CookiePartitionKey | Cookie partition key。如果未设置,cookie将被设置为未分区。 | ENCookie partition key. If not set, the cookie will be set as not partitioned. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| success | boolean | 始终设置为true。如果发生错误,响应将指示协议错误。 | ENAlways set to true. If an error occurs, the response indicates protocol error. |
🔨Network.setCookies
设置给定的cookies。
EN
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| cookies | ✔️ | | array[CookieParam] | 要设置的Cookies。 | ENCookies to be set. |
指定是否始终随此页面的请求发送额外的HTTP头。
EN
Specifies whether to always send extra HTTP headers with the requests from this page.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| headers | ✔️ | | Headers | 包含额外HTTP头部的映射。 | ENMap with extra HTTP headers. |
🔨Network.setUserAgentOverride
允许使用给定的字符串覆盖用户代理。
EN
Allows overriding user agent with the given string.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| userAgent | ✔️ | | string | 要使用的用户代理。 | ENUser agent to use. |
| acceptLanguage | | | string | 要模拟的浏览器语言。 | ENBrowser language to emulate. |
| platform | | | string | 平台 navigator.platform 应该返回。 | ENThe platform navigator.platform should return. |
| userAgentMetadata | | 🧪 | Emulation.UserAgentMetadata | 在Sec-CH-UA-*头部中发送,并在navigator.userAgentData中返回 | ENTo be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData |
🔨Network.canClearBrowserCache❌️
指示是否支持清除浏览器缓存。
EN
Tells whether clearing browser cache is supported.
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| result | boolean | 如果浏览器缓存可以被清除,则为真。 | ENTrue if browser cache can be cleared. |
🔨Network.canClearBrowserCookies❌️
指示是否支持清除浏览器Cookie。
EN
Tells whether clearing browser cookies is supported.
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| result | boolean | 如果浏览器cookie可以被清除,则为True。 | ENTrue if browser cookies can be cleared. |
🔨Network.canEmulateNetworkConditions❌️
判断是否支持网络条件模拟。
EN
Tells whether emulation of network conditions is supported.
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| result | boolean | 如果支持网络条件模 拟,则为真。 | ENTrue if emulation of network conditions is supported. |
🔨Network.emulateNetworkConditions❌️
激活网络条件模拟。此命令已弃用,推荐使用 emulateNetworkConditionsByRule 和 overrideNetworkState 命令,两者结合使用可达到相同效果。
EN
Activates emulation of network conditions. This command is deprecated in favor of the emulateNetworkConditionsByRule and overrideNetworkState commands, which can be used together to the same effect.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| offline | ✔️ | | boolean | 模拟网络断开的真实情况。 | ENTrue to emulate internet disconnection. |
| latency | ✔️ | | number | 从请求发送到响应头接收的最小延迟(毫秒)。 | ENMinimum latency from request sent to response headers received (ms). |
| downloadThroughput | ✔️ | | number | 最大聚合下载吞吐量(字节/秒)。-1 表示禁用下载限流。 | ENMaximal aggregated download throughput (bytes/sec). -1 disables download throttling. |
| uploadThroughput | ✔️ | | number | 最大聚合上传吞吐量(字节/秒)。-1 表示禁用上传限流。 | ENMaximal aggregated upload throughput (bytes/sec). -1 disables upload throttling. |
| connectionType | | | ConnectionType | 如果已知,连接类型。 | ENConnection type if known. |
| packetLoss | | 🧪 | number | WebRTC 数据包丢失率(百分比,0-100)。0 表示禁用数据包丢失模拟,100 表示丢弃所有数据包。 | ENWebRTC packet loss (percent, 0-100). 0 disables packet loss emulation, 100 drops all the packets. |
| packetQueueLength | | 🧪 | integer | WebRTC 数据包队列长度(数据包)。0 表示移除任何队列长度限制。 | ENWebRTC packet queue length (packet). 0 removes any queue length limitations. |
| packetReordering | | 🧪 | boolean | WebRTC packetReordering 功能。 | ENWebRTC packetReordering feature. |
🔨Network.getAllCookies❌️
返回所有浏览器Cookie。根据后端支持情况,将在cookies字段中返回详细的Cookie信息。已弃用。请改用Storage.getCookies。
EN
Returns all browser cookies. Depending on the backend support, will return detailed cookie information in the cookies field. Deprecated. Use Storage.getCookies instead.
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| cookies | array[Cookie] | Cookie 对象数组。 | ENArray of cookie objects. |
🔨Network.clearAcceptedEncodingsOverride🧪
清除由 setAcceptedEncodings 设置的已接受编码
EN
Clears accepted encodings set by setAcceptedEncodings
配置将响应体存储在渲染器外部,使其在跨进程导航中得以保留。如果未设置 maxTotalBufferSize,则禁用持久消息。
EN
Configures storing response bodies outside of renderer, so that these survive a cross-process navigation. If maxTotalBufferSize is not set, durable messages are disabled.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| maxTotalBufferSize | | | integer | 保留网络负载(XHR等)时使用的缓冲区大小(以字节为单位)。 | ENBuffer size in bytes to use when preserving network payloads (XHRs, etc). |
| maxResourceBufferSize | | | integer | 当保留网络负载(XHR等)时,每个资源使用的缓冲区大小(以字节为单位)。 | ENPer-resource buffer size in bytes to use when preserving network payloads (XHRs, etc). |
🔨Network.emulateNetworkConditionsByRule🧪
使用URL匹配模式为单个请求激活网络条件模拟。与已弃用的Network.emulateNetworkConditions不同,此方法不会影响navigator状态。如需显式修改navigator行为,请使用Network.overrideNetworkState。
EN
Activates emulation of network conditions for individual requests using URL match patterns. Unlike the deprecated Network.emulateNetworkConditions this method does not affect navigator state. Use Network.overrideNetworkState to explicitly modify navigator behavior.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| offline | ✔️ | | boolean | True to emulate internet disconnection. | ENTrue to emulate internet disconnection. |
| matchedNetworkConditions | ✔️ | | array[NetworkConditions] | 配置请求匹配条件。如果多个条目匹配一个请求,则第一个条目生效。通过将条件的 urlPattern 留空,可以配置全局条件。这些全局条件也适用于 P2P 连接的节流控制。 | ENConfigure conditions for matching requests. If multiple entries match a request, the first entry wins. Global conditions can be configured by leaving the urlPattern for the conditions empty. These global conditions are also applied for throttling of p2p connections. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| ruleIds | array[string] | 每个匹配网络条件条目的唯一标识符。该标识符将包含在受规则影响的请求的requestWillBeSentExtraInfo中。 | ENAn id for each entry in matchedNetworkConditions. The id will be included in the requestWillBeSentExtraInfo for requests affected by a rule. |
🔨Network.enableDeviceBoundSessions🧪
设置跟踪设备绑定的会话并获取初始会话集。
EN
Sets up tracking device bound sessions and fetching of initial set of sessions.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| enable | ✔️ | | boolean | 是否启用或禁用事件。 | ENWhether to enable or disable events. |
🔨Network.enableReportingApi🧪
启用Reporting API的跟踪功能,现在Reporting API生成的事件将被发送到客户端。启用此功能会为所有现有报告触发'reportingApiReportAdded'事件。
EN
Enables tracking for the Reporting API, events generated by the Reporting API will now be delivered to the client. Enabling triggers 'reportingApiReportAdded' for all existing reports.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| enable | ✔️ | | boolean | 是否启用或禁用Reporting API的事件 | ENWhether to enable or disable events for the Reporting API |
🔨Network.fetchSchemefulSite🧪
获取特定来源的''schemeful site''。
EN
Fetches the schemeful site for a specific origin.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| origin | ✔️ | | string | URL 来源。 | ENThe URL origin. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| schemefulSite | string | 对应的schemeful site。 | ENThe corresponding schemeful site. |
🔨Network.getCertificate🧪
返回DER编码的证书。
EN
Returns the DER-encoded certificate.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| origin | ✔️ | | string | 获取证书的来源。 | ENOrigin to get certificate for. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| tableNames | array[string] | | |
🔨Network.getResponseBodyForInterception🧪
返回为当前被拦截请求提供的内容。
EN
Returns content served for the given currently intercepted request.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| interceptionId | ✔️ | | InterceptionId | 获取请求正文的拦截请求标识符。 | ENIdentifier for the intercepted request to get body for. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| body | string | 响应正文。 | ENResponse body. |
| base64Encoded | boolean | 是的,如果内容是以base64格式发送的。 | ENTrue, if content was sent as base64. |
🔨Network.getSecurityIsolationStatus🧪
返回有关COEP/COOP隔离状态的信息。
EN
Returns information about the COEP/COOP isolation status.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| frameId | | | Page.FrameId | 如果未提供frameId,则提供目标的状态。 | ENIf no frameId is provided, the status of the target is provided. |
🔨Network.loadNetworkResource🧪
获取资源并返回内容。
EN
Fetches the resource and returns the content.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| frameId | | | Page.FrameId | 获取资源的框架ID。对于框架目标是必需的,对于工作线程目标则应省略。 | ENFrame id to get the resource for. Mandatory for frame targets, and should be omitted for worker targets. |
| url | ✔️ | | string | 获取内容的资源URL。 | ENURL of the resource to get content for. |
| options | ✔️ | | LoadNetworkResourceOptions | 请求的选项。 | ENOptions for the request. |
🔨Network.overrideNetworkState🧪
覆盖 ''navigator.onLine'' 和 ''navigator.connection'' 的状态。
EN
Override the state of navigator.onLine and navigator.connection.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| offline | ✔️ | | boolean | True to emulate internet disconnection. | ENTrue to emulate internet disconnection. |
| latency | ✔️ | | number | 从请求发送到响应头接收的最小延迟(毫秒)。 | ENMinimum latency from request sent to response headers received (ms). |
| downloadThroughput | ✔️ | | number | 最大聚合下载吞吐量(字节/秒)。-1 表示禁用下载限流。 | ENMaximal aggregated download throughput (bytes/sec). -1 disables download throttling. |
| uploadThroughput | ✔️ | | number | 最大聚合上传吞吐量(字节/秒)。-1 表示禁用上传限流。 | ENMaximal aggregated upload throughput (bytes/sec). -1 disables upload throttling. |
| connectionType | | | ConnectionType | 如果已知,连接类型。 | ENConnection type if known. |
🔨Network.replayXHR🧪
此方法发送一个与原始请求完全相同的新XMLHttpRequest。以下参数应保持一致:method、url、async、request body、extra headers、withCredentials attribute、user、password。
EN
This method sends a new XMLHttpRequest which is identical to the original one. The following parameters should be identical: method, url, async, request body, extra headers, withCredentials attribute, user, password.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| requestId | ✔️ | | RequestId | 重放XHR的标识符。 | ENIdentifier of XHR to replay. |
🔨Network.searchInResponseBody🧪