@phunky/scrape-channel-listings
Version:
A TypeScript library for scraping TV channel listings from various providers
29 lines (28 loc) • 986 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const scrapeFunction = async (page) => {
return await page.$$eval('table tr', (rows) => {
return rows.slice(1).map((row) => {
const number = row.querySelector('td:nth-child(2)')?.textContent || '';
const name = row.querySelector('td:nth-child(1)')?.textContent || '';
if (!name || !number || number.includes('-')) {
return {};
}
return { number, name };
});
});
};
const overrides = {
'CHEDDAR NEWS8': 'CHEDDAR NEWS',
'DIRECTV 4K 1': 'DIRECTV 4K',
'DIRECTV 4K LIVE 1': 'DIRECTV 4K LIVE',
'DIRECTV 4K LIVE 2 1': 'DIRECTV 4K LIVE 2',
};
const config = {
url: 'https://www.usdirect.com/channels',
scrapeFunction,
overrides,
excludeChannels: (channel) => !channel.name || !channel.number || channel.number.includes('-'),
outputFile: 'directv.json'
};
exports.default = config;