UNPKG

node-csfd-api

Version:

ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)

1 lines 1.42 kB
{"version":3,"file":"search-user.helper.mjs","names":[],"sources":["../../src/helpers/search-user.helper.ts"],"sourcesContent":["import { HTMLElement, NodeType } from 'node-html-parser';\nimport { addProtocol } from './global.helper';\n\nexport const getUser = (el: HTMLElement): string => {\n return el.querySelector('.user-title-name').text;\n};\n\nexport const getUserRealName = (el: HTMLElement): string => {\n const p = el.querySelector('.article-content p');\n if (!p) return null;\n\n const textNodes = p.childNodes.filter(n => n.nodeType === NodeType.TEXT_NODE && n.rawText.trim() !== '');\n const name = textNodes.length ? textNodes[0].rawText.trim() : null;\n\n return name;\n};\n\nexport const getAvatar = (el: HTMLElement): string => {\n const image = el.querySelector('.article-img img').attributes.src;\n return addProtocol(image);\n};\n\nexport const getUserUrl = (el: HTMLElement): string => {\n return el.querySelector('.user-title-name').attributes.href;\n};\n"],"mappings":";;;;AAGA,MAAa,WAAW,OAA4B;AAClD,QAAO,GAAG,cAAc,mBAAmB,CAAC;;AAG9C,MAAa,mBAAmB,OAA4B;CAC1D,MAAM,IAAI,GAAG,cAAc,qBAAqB;AAChD,KAAI,CAAC,EAAG,QAAO;CAEf,MAAM,YAAY,EAAE,WAAW,QAAO,MAAK,EAAE,aAAa,SAAS,aAAa,EAAE,QAAQ,MAAM,KAAK,GAAG;AAGxG,QAFa,UAAU,SAAS,UAAU,GAAG,QAAQ,MAAM,GAAG;;AAKhE,MAAa,aAAa,OAA4B;CACpD,MAAM,QAAQ,GAAG,cAAc,mBAAmB,CAAC,WAAW;AAC9D,QAAO,YAAY,MAAM;;AAG3B,MAAa,cAAc,OAA4B;AACrD,QAAO,GAAG,cAAc,mBAAmB,CAAC,WAAW"}