@trawlme/skills 1.4.8 → 1.4.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trawlme/skills",
3
- "version": "1.4.8",
3
+ "version": "1.4.10",
4
4
  "description": "Claude Code skills for the Trawl CLI — teaches Claude how to manage scraps via @trawlme/cli",
5
5
  "type": "module",
6
6
  "bin": {
@@ -38,6 +38,7 @@ const price = await page.$eval(PRICE_SEL, (el) => el.textContent.trim());
38
38
  - module-CSS (stable prefix + hash suffix) → match the prefix: `[class*="ListingCard_price"]`
39
39
  - `aria-label` often encodes the value (`[aria-label*="Current price"]`) — more stable than any class
40
40
  - **JSON beats DOM**: `window.__NEXT_DATA__` (Next.js SSR) and JSON-LD (`script[type="application/ld+json"]`, schema.org) carry the data pre-render — use as primary, DOM as fallback.
41
+ - **An XHR is not the data**: before you build on a JSON call the page makes, open its response body in a local run (`trawl-scrap-local-test`) and check it holds the rows and fields the user asked for — many JSON calls are analytics, ads or tracking.
41
42
 
42
43
  ## Waits
43
44
 
@@ -121,6 +122,31 @@ try {
121
122
  - Page never loaded or returned a fatal error
122
123
  - Required param missing
123
124
 
125
+ ## Run budget
126
+
127
+ One run has a **time budget**: about **10 minutes** from dispatch, and the clock starts before your script does (the run may queue first). Past it the worker stops the run and nothing is returned. Time is almost always the limit, not size: the whole output may reach tens of MB before a run fails with `output too large`.
128
+
129
+ - Add a **deadline guard**: note `Date.now()` at the start, stop about **7 minutes** in, and `returnData` the rows read so far, with `truncated: true` on the last one (the platform reads it as a marker that the run stopped early, not as a data column). The guard runs between requests, so also give each request its own timeout (e.g. `fetch(url, { signal: AbortSignal.timeout(20000) })` inside `page.evaluate`, with a `try`/`catch` that breaks the loop): one stuck page must not carry the run past its budget.
130
+ - Read fewer, cheaper pages: each `page.goto` costs seconds on its own. For lists, prefer same-origin `fetch` from inside the page (`page.evaluate`) on JSON feeds, pagination or search APIs, sitemaps. One request at a time, never parallel tabs or `page.goto`s to the same site (several loads within a few seconds can get the run blocked). Space requests about 1 s apart: that pause is rate-limit politeness (`references/anti-patterns.md`), never a wait for the page.
131
+ - A catalog that cannot fit one run is still scrapable:
132
+ - **targeted** — only the items you need, by search or by their URLs (passed as a param), not the whole catalog;
133
+ - **split** — one scrap per category or section, each small enough for one run; each scrap keeps its own rows. Slices of ONE scrap across runs (a different param per run) replace each other's rows, unless the scrap's `items` option keeps them (`keepData`, set by the Trawl team on request).
134
+
135
+ ```js
136
+ const started = Date.now();
137
+ const STOP_AFTER_MS = 7 * 60 * 1000;
138
+ const rows = [];
139
+ for (const url of productUrls) { // your list, e.g. from a param or a sitemap
140
+ if (Date.now() - started > STOP_AFTER_MS) {
141
+ if (rows.length) rows[rows.length - 1].truncated = true; // marks where the run stopped
142
+ break;
143
+ }
144
+ // … fetch one product (awaited), push it to rows
145
+ await new Promise((r) => setTimeout(r, 1000)); // politeness between requests
146
+ }
147
+ returnData(rows);
148
+ ```
149
+
124
150
  ## Hard anti-bot sites
125
151
 
126
152
  The platform auto-escalates proxy tiers when a run comes back empty — you usually don't manage tiers at all. For a site you *know* is heavily protected, there are two CLI knobs (see the `trawl-cli` skill for full flag docs):
@@ -22,7 +22,7 @@ Source: [browser-use.com/posts/bot-detection](https://browser-use.com/posts/bot-
22
22
 
23
23
  ## No random jitter as primary defence
24
24
 
25
- Bot detection decides at the fingerprint level — milliseconds before any timing signal exists. `Math.random() * 500` delays have no effect. Small jitter (200–800ms) is acceptable for **rate-limit politeness** only, never as an anti-bot mechanism.
25
+ Bot detection decides at the fingerprint level — milliseconds before any timing signal exists. `Math.random() * 500` delays have no effect. Small jitter (200–800ms), or a pause of about 1 s between two requests to the same site, is acceptable for **rate-limit politeness** only, never as an anti-bot mechanism.
26
26
 
27
27
  Source: [browser-use.com/posts/bot-detection](https://browser-use.com/posts/bot-detection)
28
28
 
@@ -30,7 +30,7 @@ Source: [browser-use.com/posts/bot-detection](https://browser-use.com/posts/bot-
30
30
 
31
31
  ## No fixed setTimeout / waitForTimeout
32
32
 
33
- `page.waitForTimeout(N)` is deprecated. `setTimeout` is unreliable under load and slows every run unconditionally. Use state-based waits:
33
+ `page.waitForTimeout(N)` is deprecated. `setTimeout` is unreliable under load and slows every run unconditionally. The one exception is the ~1 s pause between two requests to the same site (rate-limit politeness, see Run budget in the skill), never a wait for the page. Use state-based waits:
34
34
  - `page.waitForSelector(selector)` — most targeted
35
35
  - `page.waitForNetworkIdle()` — for SPA-heavy pages
36
36
  - `page.waitForFunction(fn)` — for complex DOM conditions