如果我有这个
page.on('response', this.extractImages);
第一个问题:如何将其他变量传递给this.extractImages
函数?该功能被定义为extractImages(...args)
但args
仅此而已:
[ Response {
_client:
Session {
domain: null,
_events: [Object],
_eventsCount: 15,
_maxListeners: undefined,
_lastId: 9,
_callbacks: Map {},
_connection: [Object],
_targetId: '3879dfee-f3de-48a8-a735-ac3b8cb4110e',
_sessionId: '3879dfee-f3de-48a8-a735-ac3b8cb4110e:1' },
_request:
Request {
_client: [Object],
_requestId: '39213.259',
_interceptionId: null,
_interceptionHandled: false,
_response: [Circular],
_completePromiseFulfill: [Function],
_completePromise: [Object],
url: 'https://cm.g.doubleclick.net/pixel?google_nid=rubicon&google_cm&google_sc&google_awbid',
method: 'GET',
postData: undefined,
headers: [Object] },
_contentPromise: null,
headers:
Map {
'pragma' => 'no-cache',
'date' => 'Sat, 09 Sep 2017 06:46:10 GMT',
'server' => 'HTTP server (unknown)',
'status' => '302',
'p3p' => 'policyref="https://googleads.g.doubleclick.net/pagead/gcn_p3p_.xml", CP="CURa ADMa DEVa TAIo PSAo PSDo OUR IND UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"',
'location' => 'https://pixel.rubiconproject.com/tap.php?v=7751&nid=2249&expires=30&put=CAESEBK_unCwxxtI7mj-7CUjh3g&google_cver=1',
'cache-control' => 'no-cache, must-revalidate',
'content-type' => 'text/html; charset=UTF-8',
'alt-svc' => 'quic="googleads.g.doubleclick.net:443"; ma=2592000; v="39,38,37,35",quic=":443"; ma=2592000; v="39,38,37,35"',
'content-length' => '326',
'x-xss-protection' => '1; mode=block',
'expires' => 'Fri, 01 Jan 1990 00:00:00 GMT' },
status: 302,
ok: false,
url: 'https://cm.g.doubleclick.net/pixel?google_nid=rubicon&google_cm&google_sc&google_awbid' } ]
第二个问题:如何从page.on
触发的函数中获得返回(在本例中为:) this.extractImages
?