The Content Automation Pipeline
What a pipeline is
Section titled “What a pipeline is”One continuous chain:
monitor source → scrape → process/generate → publish → logTypical use: watch several sources, translate or rewrite what’s new, and publish — no human in the loop.
Design principles
Section titled “Design principles”Principle 1: scripts must run without interaction
Section titled “Principle 1: scripts must run without interaction”Nothing is there to answer a prompt. Anything waiting on input hangs forever.
// ❌ hangsconst answer = await prompt('Publish now?')
// ✅ configuration insteadconst BACKFILL_ENABLED = falseconst HEADLESS = trueTurn every decision point into a config value up front.
Principle 2: logs go to a file
Section titled “Principle 2: logs go to a file”node monitor.js >> cron.log 2>&1Automation without logs means guessing when something breaks. Record what ran, how many items were found, how many succeeded, and why failures failed.
Principle 3: separate new from historical
Section titled “Principle 3: separate new from historical”A freshly deployed monitor without bounds will republish months of old content.
Track processed IDs, and put historical backfill behind a flag that’s off by default.
Principle 4: idempotency
Section titled “Principle 4: idempotency”Running twice shouldn’t duplicate output. Record what’s been processed and skip it next time.
Scraping considerations
Section titled “Scraping considerations”Network Some sources need a proxy depending on your region. Configure it explicitly in the script; don’t rely on system settings.
Page loading
Waiting for networkidle times out constantly. Switch to domcontentloaded plus an explicit wait for the target element — much more reliable.
Being polite Throttle requests, set reasonable headers, and space out batch scraping.
Generation
Section titled “Generation”Scraped content usually needs work:
- Translation (specify target language, preserve proper nouns)
- Rewriting (restructure and resize for the destination platform)
- Formatting (match platform conventions)
Always keep source links and attribution — both respect and traceability.
Publishing
Section titled “Publishing”When publishing through an API:
- Test with scheduled publishing first, not immediate — review, then release manually
- Record publish results (successful and failed IDs)
- Retry transient failures carefully, guarding against duplicates
A configuration example
Section titled “A configuration example”module.exports = { accounts: ['@account1', '@account2'], checkInterval: '0 */2 * * *', headless: true, proxy: 'http://127.0.0.1:7897', backfillEnabled: false, // historical republish, default off logFile: './cron.log', publishMode: 'scheduled', // schedule, don't publish immediately}Monitoring your monitoring
Section titled “Monitoring your monitoring”Launching isn’t the finish line — you need to know when it dies:
- N consecutive failures → needs human attention
- No output for a long stretch → the source may have changed structure
- Read the log manually once a week
The most overlooked failure mode: a source redesigns, selectors stop matching, and you scrape empty results. This “silent failure” is the worst kind — the job looks healthy and produces nothing.
Hands-on track complete
Section titled “Hands-on track complete”Five scenarios, one recurring method: scan read-only first, batch the changes, write logs, leave yourself an undo.
Next: the Power User track.