xiaohongshu
xiaohongshu
dribl-crawling
Document patterns for crawling dribl.com fixtures website using playwright-core to extract clubs and fixtures data with Cloudflare protection. Covers extraction (crawling with API interception) and transformation (Zod validation, data merging) phases.
Full skill instructions
Extract clubs and fixtures data from https://fv.dribl.com/fixtures/ (SPA with Cloudflare protection) using real browser automation with playwright-core. Two-phase workflow: extraction (raw API data) → transformation (validated, merged data).
Purpose: Crawl dribl.com to maintain up-to-date clubs and fixtures data for Williamstown SC website.
Data flow:
dribl API → data/external/fixtures/{team}/ (raw) → transform → data/matches/ (validated)
dribl API → data/external/clubs/ (raw) → transform → data/clubs/ (validated)
Two-phase pattern:
Key technologies:
Reference: bin/crawlClubs.ts
Pattern:
// Launch browser
const browser = await chromium.launch({
headless: false,
channel: 'chrome'
});
// Custom user agent (bypass detection)
const context = await browser.newContext({
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36...',
viewport: { width: 1280, height: 720 }
});
// Intercept API request
const [clubsResponse] = await Promise.all([
page.waitForResponse((response) => response.url().startsWith(clubsApiUrl) && response.ok(), {
timeout: 60_000
}),
page.goto(url, { waitUntil: 'domcontentloaded' })
]);
// Validate and save
const rawData = await clubsResponse.json();
const validated = externalApiResponseSchema.parse(rawData);
writeFileSync(outputPath, JSON.stringify(validated, null, '\t') + '\n');
API endpoint:
https://mc-api.dribl.com/api/list/clubs?disable_paging=truedata array of club objectsexternalApiResponseSchema (src/types/matches.ts)Output:
data/external/clubs/clubs.jsonCLI args:
--url <fixtures-page-url> (optional, defaults to standard fixtures page)Pattern (implemented in bin/crawlFixtures.ts):
Steps:
waitUntil: 'domcontentloaded')/api/fixtures responseschunk-{index}.jsonAPI endpoint:
https://mc-api.dribl.com/api/fixturesdata array, links (next/prev), meta (cursors)externalFixturesApiResponseSchemaOutput:
data/external/fixtures/{team}/chunk-0.json, chunk-1.json, etc.chunk-{index}.json where index starts at 0CLI args:
--team <slug> (required) - Team slug for output folder (e.g., "senior-mens")--league <slug> (required) - League slug for filtering (e.g., "State League 2 Men's - North-West")--season <year> (optional, default to current year)--competition <id> (optional, default to FFV)Reference: bin/syncClubs.ts
Pattern:
// Load external data
const externalResponse = loadExternalData(); // from data/external/clubs/
const validated = externalApiResponseSchema.parse(externalResponse);
// Transform to internal format
const apiClubs = externalResponse.data.map((externalClub) => transformExternalClub(externalClub));
// Load existing clubs
const existingFile = loadExistingClubs(); // from data/clubs/
// Merge (deduplicate by externalId)
const clubsMap = new Map<string, Club>();
for (const club of existingClubs) {
clubsMap.set(club.externalId, club);
}
for (const apiClub of apiClubs) {
clubsMap.set(apiClub.externalId, apiClub); // update or add
}
// Sort by name
const mergedClubs = Array.from(clubsMap.values()).sort((a, b) => a.name.localeCompare(b.name));
// Save
writeFileSync(CLUBS_FILE_PATH, JSON.stringify({ clubs: mergedClubs }, null, '\t'));
Transform service: src/lib/clubService.ts
transformExternalClub(): Converts external club format to internal formatclubSchemaOutput:
data/clubs/clubs.json{ clubs: Club[] }Reference: bin/syncFixtures.ts
Pattern:
// Read all chunk files
const teamDir = path.join(EXTERNAL_DIR, team);
const files = await fs.readdir(teamDir);
const chunkFiles = files.filter((f) => f.match(/^chunk-\d+\.json$/)).sort(); // natural number sort
// Load and validate each chunk
const responses: ExternalFixturesApiResponse[] = [];
for (const file of chunkFiles) {
const content = await fs.readFile(path.join(teamDir, file), 'utf-8');
const validated = externalFixturesApiResponseSchema.parse(JSON.parse(content));
responses.push(validated);
}
// Transform all fixtures
const allFixtures = [];
for (const response of responses) {
for (const externalFixture of response.data) {
const fixture = transformExternalFixture(externalFixture);
allFixtures.push(fixture);
}
}
// Deduplicate (by round + homeTeamId + awayTeamId)
const seen = new Set<string>();
const deduplicated = allFixtures.filter((f) => {
const key = `${f.round}-${f.homeTeamId}-${f.awayTeamId}`;
if (seen.has(key)) return false;
seen.add(key);
return true;
});
// Sort by round, then date
const sorted = deduplicated.sort((a, b) => {
if (a.round !== b.round) return a.round - b.round;
return a.date.localeCompare(b.date);
});
// Calculate metadata
const totalRounds = Math.max(...sorted.map((f) => f.round), 0);
// Save
const fixtureData = {
competition: 'FFV',
season: 2025,
totalFixtures: sorted.length,
totalRounds,
fixtures: sorted
};
writeFileSync(outputPath, JSON.stringify(fixtureData, null, '\t'));
Transform service: src/lib/matches/fixtureTransformService.ts
transformExternalFixture(): Converts external fixture format to internal formatfixtureSchemaOutput:
data/matches/{team}.json{ competition, season, totalFixtures, totalRounds, fixtures: Fixture[] }CLI args:
--team <slug> (required) - Team slug to sync (e.g., "senior-mens")Reference: src/types/matches.ts
External schemas (API responses):
externalApiResponseSchema: Clubs API responseexternalClubSchema: Single club objectexternalFixturesApiResponseSchema: Fixtures API responseexternalFixtureSchema: Single fixture objectInternal schemas (transformed data):
clubSchema: Single clubclubsSchema: Clubs file ({ clubs: Club[] })fixtureSchema: Single fixturefixtureDataSchema: Fixtures file ({ competition, season, totalFixtures, totalRounds, fixtures })Pattern: Always validate at boundaries (API → external schema, transform → internal schema)
Reference: .github/workflows/crawl-clubs.yml
Linux setup (GitHub Actions):
- name: Install Chrome
run: npx playwright install --with-deps chrome
- name: Crawl clubs
run: npm run crawl:clubs:ci -- ${{ inputs.url && format('--url "{0}"', inputs.url) || '' }}
Key points:
xvfb-run prefix on Linux for headless Chrome (e.g., xvfb-run npm run crawl:clubs)--with-deps flag to get system dependenciesPackage.json scripts pattern:
{
"crawl:clubs": "tsx bin/crawlClubs.ts",
"crawl:clubs:ci": "xvfb-run tsx bin/crawlClubs.ts",
"sync:clubs": "tsx bin/syncClubs.ts",
"sync:fixtures": "tsx bin/syncFixtures.ts"
}
Logging:
Error handling:
File operations:
mkdirSync(path, { recursive: true }) before writingJSON.stringify(data, null, '\t')content + '\n'resolve(__dirname, '../relative/path')Data separation:
data/external/ (gitignored)data/ (committed)Validation:
CLI arguments:
.option() or .requiredOption()Reading chunks:
const files = await fs.readdir(dir);
const chunks = files
.filter((f) => f.match(/^chunk-\d+\.json$/))
.sort((a, b) => {
const numA = parseInt(a.match(/\d+/)?.[0] || '0', 10);
const numB = parseInt(b.match(/\d+/)?.[0] || '0', 10);
return numA - numB;
});
Deduplication:
const seen = new Set<string>();
const unique = items.filter((item) => {
const key = computeKey(item);
if (seen.has(key)) return false;
seen.add(key);
return true;
});
Merge with existing:
const map = new Map<string, T>();
existing.forEach((item) => map.set(item.id, item));
incoming.forEach((item) => map.set(item.id, item)); // update or add
const merged = Array.from(map.values());
Browser cleanup:
let browser: Browser | undefined;
try {
browser = await chromium.launch(...);
// work
} finally {
if (browser) await browser.close();
}
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience