# class:response
### class: Response v0.9.0
[Response](#?product=Puppeteer&version=v1.11.0&show=api-class-response "Response") 类表示页面接收的响应。
#### Methods
- [response.buffer()](#?product=Puppeteer&version=v1.11.0&show=api-responsebuffer)v0.9.0
- [response.frame()](#?product=Puppeteer&version=v1.11.0&show=api-responseframe)v0.9.0
- [response.fromCache()](#?product=Puppeteer&version=v1.11.0&show=api-responsefromcache)v0.9.0
- [response.fromServiceWorker()](#?product=Puppeteer&version=v1.11.0&show=api-responsefromserviceworker)v0.9.0
- [response.headers()](#?product=Puppeteer&version=v1.11.0&show=api-responseheaders)v0.9.0
- [response.json()](#?product=Puppeteer&version=v1.11.0&show=api-responsejson)v0.9.0
- [response.ok()](#?product=Puppeteer&version=v1.11.0&show=api-responseok)v0.9.0
- [response.remoteAddress()](#?product=Puppeteer&version=v1.11.0&show=api-responseremoteaddress)v0.9.0
- [response.request()](#?product=Puppeteer&version=v1.11.0&show=api-responserequest)v0.9.0
- [response.securityDetails()](#?product=Puppeteer&version=v1.11.0&show=api-responsesecuritydetails)v0.9.0
- [response.status()](#?product=Puppeteer&version=v1.11.0&show=api-responsestatus)v0.9.0
- [response.statusText()](#?product=Puppeteer&version=v1.11.0&show=api-responsestatustext)v0.9.0
- [response.text()](#?product=Puppeteer&version=v1.11.0&show=api-responsetext)v0.9.0
- [response.url()](#?product=Puppeteer&version=v1.11.0&show=api-responseurl)v0.9.0
### Methods
#### response.buffer()v0.9.0
- returns: > Promise which resolves to a buffer with response body.
#### response.frame()v0.9.0
- returns: <?[Frame](#?product=Puppeteer&version=v1.11.0&show=api-class-frame "Frame")> 响应请求的 [Frame](#?product=Puppeteer&version=v1.11.0&show=api-class-frame "Frame"),如果导航到错误页面,则为`null`。
#### response.fromCache()v0.9.0
- returns: <[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean")>
如果响应来自浏览器的磁盘缓存或内存缓存,则为 true。
#### response.fromServiceWorker()v0.9.0
- returns: <[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean")>
如果响应是由 service worker 提供的,则为 true。
#### response.headers()v0.9.0
- returns: <[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object")> 具有与响应关联的 HTTP 头对象。 所有标题名称都是小写。
#### response.json()v0.9.0
- returns: > Promise which resolves to a JSON representation of response body.
如果响应主体无法进行 `JSON.parse` 解析,则此方法将抛出错误。
#### response.ok()v0.9.0
- returns: <[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean")>
包含一个布尔值,说明响应是否成功(状态范围为200-299)。
#### response.remoteAddress()v0.9.0
- returns: <[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object")>
- `ip` <[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "String")> 远程服务的 IP 地址
- `port` <[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number")> 连接远程服务的端口号
#### response.request()v0.9.0
- returns: <[Request](#?product=Puppeteer&version=v1.11.0&show=api-class-request "Request")> 一个匹配的 [Request](#?product=Puppeteer&version=v1.11.0&show=api-class-request "Request") 对象.
#### response.securityDetails()v0.9.0
- returns: <?[SecurityDetails](#?product=Puppeteer&version=v1.11.0&show=api-class-securitydetails "SecurityDetails")> 如果通过安全连接接收到响应,则为安全细节,否则为`null`。
#### response.status()v0.9.0
- returns: <[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number")>
包含响应的状态代码(例如,200成功)。
#### response.statusText()v0.9.0
- returns: <[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "String")>
包含响应的状态文本(例如,通常成功的 "OK")。
#### response.text()v0.9.0
- returns: <[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise "Promise")<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "String")>> Promise which resolves to a text representation of response body.
#### response.url()v0.9.0
- returns: <[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "String")>
包含响应的 URL。
![](images/pptr.png)
puppeteer.js中文网|class:response
puppeteer.js中文文档, puppeteer chrome, puppeteer firefox, puppeteer api 中文文档
puppeteer.js中文网包含了Puppeteer中文文档,最新资讯,应用案例等。Puppeteer 是一个 Node 库,它提供了一个高级 API 来通过 DevTools 协议控制 Chromium 或 Chrome。
- Introduction
- 版本记录
- 概要
- puppeteer-vs-puppeteer-core
- 环境变量
- error-handling
- working-with-chrome-extensions
- class:puppeteer
- class:browserfetcher
- class:browser
- class:page
- class:worker
- class:accessibility
- class:keyboard
- class:mouse
- class:touchscreen
- class:tracing
- class:dialog
- class:consolemessage
- class:frame
- class:executioncontext
- class:jshandle
- class:elementhandle
- class:request
- class:response
- class:securitydetails
- class:target
- class:cdpsession
- class:coverage
- class:timeouterror