* Extract links from the document
($: cheerio.CheerioAPI)
| 266 | * Extract links from the document |
| 267 | */ |
| 268 | private extractLinks($: cheerio.CheerioAPI): Array<{ text: string; href: string }> { |
| 269 | const links: Array<{ text: string; href: string }> = [] |
| 270 | |
| 271 | $('a[href]').each((_, element) => { |
| 272 | const $element = $(element) |
| 273 | const href = $element.attr('href') |
| 274 | const text = $element.text().trim() |
| 275 | |
| 276 | if (href && text && href.startsWith('http')) { |
| 277 | links.push({ text, href }) |
| 278 | } |
| 279 | }) |
| 280 | |
| 281 | return links |
| 282 | } |
| 283 | } |
no test coverage detected