Get Uniquly Filtered Data Via Inspect Console
Aditya Dand
1 min read
const anchorTags = document.querySelectorAll('a'); const filteredLinks = []; const memberIds = new Set();
anchorTags.forEach(anchor => { const href = anchor.getAttribute('href'); if (!href || !href.startsWith("https://")) return; // Skip invalid links
// Check if member ID is in the href const memberIdMatch = href.match(//directory/members/(\d+)/); if (!memberIdMatch) return; // Skip if member ID not found
const memberId = memberIdMatch[1]; if (!memberId || memberIds.has(memberId)) return; // Skip duplicates
memberIds.add(memberId); filteredLinks.push(href); });
console.log(filteredLinks);
change accordingly to your need
0
Subscribe to my newsletter
Read articles from Aditya Dand directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by