unprint 0.17.1 → 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/package.json +1 -1
- package/src/app.js +10 -3
- package/tests/browser.js +2 -3
package/README.md
CHANGED
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -1074,7 +1074,7 @@ async function closeAllBrowsers() {
|
|
|
1074
1074
|
await Promise.all(Array.from(clients.values()).map(async (client) => client.browser.close()));
|
|
1075
1075
|
}
|
|
1076
1076
|
|
|
1077
|
-
function curateResponse(res, options, { url, customOptions }) {
|
|
1077
|
+
function curateResponse(res, options, { url, control, customOptions }) {
|
|
1078
1078
|
const base = {
|
|
1079
1079
|
ok: true,
|
|
1080
1080
|
status: res.status,
|
|
@@ -1082,6 +1082,7 @@ function curateResponse(res, options, { url, customOptions }) {
|
|
|
1082
1082
|
headers: res.headers,
|
|
1083
1083
|
response: res,
|
|
1084
1084
|
res,
|
|
1085
|
+
control,
|
|
1085
1086
|
};
|
|
1086
1087
|
|
|
1087
1088
|
if (['application/json', 'application/javascript'].some((type) => res.headers['content-type']?.includes(type)) && typeof res.data === 'object') {
|
|
@@ -1164,8 +1165,10 @@ async function browserRequest(url, customOptions = {}) {
|
|
|
1164
1165
|
|
|
1165
1166
|
await page.waitForLoadState();
|
|
1166
1167
|
|
|
1168
|
+
let control = null;
|
|
1169
|
+
|
|
1167
1170
|
if (customOptions.control) {
|
|
1168
|
-
await customOptions.control(page, { context, browser });
|
|
1171
|
+
control = await customOptions.control(page, { context, browser });
|
|
1169
1172
|
}
|
|
1170
1173
|
|
|
1171
1174
|
events.emit('controlSuccess', feedbackBase);
|
|
@@ -1184,7 +1187,11 @@ async function browserRequest(url, customOptions = {}) {
|
|
|
1184
1187
|
status,
|
|
1185
1188
|
statusText,
|
|
1186
1189
|
headers,
|
|
1187
|
-
}, options, {
|
|
1190
|
+
}, options, {
|
|
1191
|
+
url,
|
|
1192
|
+
customOptions,
|
|
1193
|
+
control,
|
|
1194
|
+
});
|
|
1188
1195
|
});
|
|
1189
1196
|
}
|
|
1190
1197
|
|
package/tests/browser.js
CHANGED
|
@@ -8,7 +8,6 @@ async function initTest() {
|
|
|
8
8
|
browser: {
|
|
9
9
|
headless: false,
|
|
10
10
|
},
|
|
11
|
-
scope: null,
|
|
12
11
|
async control(_page) {
|
|
13
12
|
//
|
|
14
13
|
},
|
|
@@ -22,7 +21,6 @@ async function initTest() {
|
|
|
22
21
|
browser: {
|
|
23
22
|
headless: false,
|
|
24
23
|
},
|
|
25
|
-
scope: null,
|
|
26
24
|
async control(_page) {
|
|
27
25
|
//
|
|
28
26
|
},
|
|
@@ -34,13 +32,14 @@ async function initTest() {
|
|
|
34
32
|
// await unprint.browser('https://www.scrapingcourse.com/', {
|
|
35
33
|
headless: false,
|
|
36
34
|
async control(_page) {
|
|
37
|
-
|
|
35
|
+
return 'test';
|
|
38
36
|
},
|
|
39
37
|
});
|
|
40
38
|
|
|
41
39
|
const cards = res.context.query.contents('h2');
|
|
42
40
|
|
|
43
41
|
console.log('CARD TITLES', cards);
|
|
42
|
+
console.log('CONTROL OUT', res.control);
|
|
44
43
|
|
|
45
44
|
await unprint.closeAllBrowsers();
|
|
46
45
|
}
|