@phunky/scrape-channel-listings
Version:
A TypeScript library for scraping TV channel listings from various providers
45 lines (44 loc) • 1.4 kB
JavaScript
;
/**
* DISH Network Channel Listing Scraper
* Extracts channel numbers and names from DISH's channel lineup
*/
Object.defineProperty(exports, "__esModule", { value: true });
const scraper_1 = require("../utils/scraper");
/**
* Extracts channel information from the DISH channel listing page
* @param page - Playwright page instance
* @returns Array of partial channel objects containing number and name
*/
const scrapeFunction = async (page) => {
return await page.$$eval('#dish-channel-guide tbody tr', (rows) => {
return rows.map((row) => {
const number = row.querySelector('td.column-2')?.textContent?.trim() || '';
const name = row.querySelector('td.column-1')?.textContent?.trim() || '';
if (!name || number.includes('-')) {
return {};
}
return { number, name };
});
});
};
/**
* Channel name overrides to standardize naming across providers
*/
const overrides = {
'NICK': 'NICKELODEON'
};
/**
* DISH Network scraper configuration
*/
const config = {
url: 'https://www.allconnect.com/providers/dish/channel-guide',
scrapeFunction,
overrides,
outputFile: 'dish.json'
};
// Run scraper if this file is executed directly
if (require.main === module) {
(0, scraper_1.runScraperCLI)(config).catch(() => process.exit(1));
}
exports.default = config;