unprint 0.19.12 → 0.19.14

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/app.js +6 -13
package/README.md CHANGED
@@ -299,7 +299,7 @@ You can run unprint as a Playwright browser server. This is particularly useful
299
299
 
300
300
  #### Server
301
301
  * Ensure optional dependencies are installed
302
- * `npm start server` or `node src/server.js`
302
+ * `npm run server` or `node src/server.js`
303
303
 
304
304
  Environment variables (optional, .env is supported):
305
305
  * `UNPRINT_HOST`: Server host, default `127.0.0.1:3333`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unprint",
3
- "version": "0.19.12",
3
+ "version": "0.19.14",
4
4
  "description": "Simplify common web scraping tasks while staying in control of the data.",
5
5
  "main": "src/app.js",
6
6
  "scripts": {
package/src/app.js CHANGED
@@ -1167,7 +1167,7 @@ function curateResponse(res, data, options, { url, control, customOptions }) {
1167
1167
  control,
1168
1168
  };
1169
1169
 
1170
- if (['application/json', 'application/javascript'].some((type) => {
1170
+ if (res.headers && ['application/json', 'application/javascript'].some((type) => {
1171
1171
  if (typeof res.headers.get === 'function') {
1172
1172
  return res.headers.get('content-type')?.includes(type);
1173
1173
  }
@@ -1434,18 +1434,11 @@ async function browserRequest(url, customOptions = {}) {
1434
1434
 
1435
1435
  const page = await client.context.newPage();
1436
1436
 
1437
- await page.route(url, async (route) => {
1438
- const headers = route.request().headers();
1439
-
1440
- route.continue({
1441
- headers: curateHeaders({
1442
- ...headers,
1443
- 'user-agent': options.browserUserAgent || options.userAgent,
1444
- ...options.headers,
1445
- cookie: getCookie(options),
1446
- }, options),
1447
- });
1448
- });
1437
+ await page.setExtraHttpHeaders(curateHeaders({
1438
+ 'user-agent': options.browserUserAgent || options.userAgent,
1439
+ ...options.headers,
1440
+ cookie: getCookie(options),
1441
+ }, options));
1449
1442
 
1450
1443
  const res = await page.goto(url, {
1451
1444
  ...options.page,