@imenam/simple-scraper 1.0.20 → 1.0.21
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 +2 -2
- package/dist/cookies.js +2 -0
- package/dist/gui.js +8 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ other servers are preserved, and an existing `simple-scraper-mcp` entry is only
|
|
|
57
57
|
| `PUPPETEER_VIEWPORT_WIDTH` | No | `1280` | Viewport width in CSS pixels, applied to every page. Affects responsive layouts and lazy-loading, not just screenshots. |
|
|
58
58
|
| `PUPPETEER_VIEWPORT_HEIGHT` | No | `800` | Viewport height in CSS pixels, applied to every page. |
|
|
59
59
|
| `PUPPETEER_DEVICE_SCALE_FACTOR` | No | `1` | Physical pixels per CSS pixel. Set to `2` for retina-density screenshots (same framing, twice the detail, ~4× the file size). |
|
|
60
|
-
| `COOKIES_DIR` | No | - | Absolute path to a folder containing Netscape-format `.txt` cookie files. All files are loaded and merged automatically before each request. |
|
|
60
|
+
| `COOKIES_DIR` | No | - | Absolute path to a folder containing Netscape-format `.txt` cookie files. The folder is created automatically if it does not exist. All files are loaded and merged automatically before each request. |
|
|
61
61
|
| `MCP_LOG_DIR` | No | `.mcp-gui/logs` | Absolute path to the directory where log files are written. |
|
|
62
62
|
| `PROXY_URL` | No | - | Base URL of the [MCP HTTP Gateway](https://www.npmjs.com/package/@imenam/mcp-http-gateway). Required to enable the GUI. |
|
|
63
63
|
| `PROXY_APP_PATH` | No | `/simple-scraper-mcp` | URL path under which the GUI is registered on the proxy. |
|
|
@@ -372,7 +372,7 @@ The capture area is resolved by precedence: `selector` → `clip` → `full_page
|
|
|
372
372
|
|
|
373
373
|
## Cookie Files
|
|
374
374
|
|
|
375
|
-
Cookies are loaded from `.txt` files in [Netscape format](http://www.cookiecentral.com/faq/#3.5). Place them in the folder specified by `COOKIES_DIR`. All files in the folder are loaded and merged automatically before each request.
|
|
375
|
+
Cookies are loaded from `.txt` files in [Netscape format](http://www.cookiecentral.com/faq/#3.5). Place them in the folder specified by `COOKIES_DIR`. All files in the folder are loaded and merged automatically before each request. If the folder does not exist yet, it is created automatically (including any missing parent directories), so a fresh `COOKIES_DIR` no longer raises an error.
|
|
376
376
|
|
|
377
377
|
## GUI (Optional)
|
|
378
378
|
|
package/dist/cookies.js
CHANGED
|
@@ -21,6 +21,7 @@ export function parseNetscapeCookies(content) {
|
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* Loads and merges all cookie files from the COOKIES_DIR directory.
|
|
24
|
+
* The directory is created if it does not exist yet.
|
|
24
25
|
* Silently returns an empty array if COOKIES_DIR is not set.
|
|
25
26
|
*/
|
|
26
27
|
export async function loadAllCookies() {
|
|
@@ -29,6 +30,7 @@ export async function loadAllCookies() {
|
|
|
29
30
|
return [];
|
|
30
31
|
let files;
|
|
31
32
|
try {
|
|
33
|
+
await fs.mkdir(cookiesDir, { recursive: true });
|
|
32
34
|
files = await fs.readdir(cookiesDir);
|
|
33
35
|
}
|
|
34
36
|
catch {
|
package/dist/gui.js
CHANGED
|
@@ -61,7 +61,14 @@ process.on('unhandledRejection', (reason) => {
|
|
|
61
61
|
console.error(`[GUI] Unhandled Rejection: ${reason}`);
|
|
62
62
|
process.exit(1);
|
|
63
63
|
});
|
|
64
|
-
|
|
64
|
+
/** Retourne COOKIES_DIR en le créant au besoin (null si non configuré). */
|
|
65
|
+
const getCookiesDir = () => {
|
|
66
|
+
const cookiesDir = process.env.COOKIES_DIR ?? null;
|
|
67
|
+
if (!cookiesDir)
|
|
68
|
+
return null;
|
|
69
|
+
fs.mkdirSync(cookiesDir, { recursive: true });
|
|
70
|
+
return cookiesDir;
|
|
71
|
+
};
|
|
65
72
|
const app = express();
|
|
66
73
|
app.use(bodyParser.json());
|
|
67
74
|
app.use(express.static(path.join(rootDir, 'public/dist')));
|