UNPKG

node-csfd-api

Version:

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

1 lines 1.5 kB
{"version":3,"file":"search-user.helper.cjs","names":["NodeType","addProtocol"],"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;CAClD,OAAO,GAAG,cAAc,kBAAkB,CAAC,CAAC;AAC9C;AAEA,MAAa,mBAAmB,OAA4B;CAC1D,MAAM,IAAI,GAAG,cAAc,oBAAoB;CAC/C,IAAI,CAAC,GAAG,OAAO;CAEf,MAAM,YAAY,EAAE,WAAW,QAAO,MAAK,EAAE,aAAaA,iBAAAA,SAAS,aAAa,EAAE,QAAQ,KAAK,MAAM,EAAE;CAGvG,OAFa,UAAU,SAAS,UAAU,EAAE,CAAC,QAAQ,KAAK,IAAI;AAGhE;AAEA,MAAa,aAAa,OAA4B;CACpD,MAAM,QAAQ,GAAG,cAAc,kBAAkB,CAAC,CAAC,WAAW;CAC9D,OAAOC,sBAAAA,YAAY,KAAK;AAC1B;AAEA,MAAa,cAAc,OAA4B;CACrD,OAAO,GAAG,cAAc,kBAAkB,CAAC,CAAC,WAAW;AACzD"}