Skip to content

Instantly share code, notes, and snippets.

@RohanAwhad
RohanAwhad / extractAndDownloadApolloSearchResults.js
Last active October 29, 2024 15:51
Extract details from the search response in Apollo.io
function extractRowData(rowElement) {
// Function to extract text or attribute from an element if it exists
function getElementData(selector, attribute = 'text') {
const element = rowElement.querySelector(selector);
if (!element) return null;
if (attribute === 'text') return element.textContent.trim();
return element.getAttribute(attribute);
}
// Extracting the values based on their aria-label, role, or data-* attributes
(function() {
// Initialize an array to hold the conversation data
let conversationData = [];
// Select all conversation blocks
let conversationBlocks = document.querySelectorAll('[data-testid^="conversation-turn"]');
conversationBlocks.forEach(block => {
// Determine the role directly from data attributes in the HTML
let roleElement = block.querySelector('[data-message-author-role]');
// Updated extractLinkedInPosts function with continuous scrolling
async function extractLinkedInPosts() {
const postsData = [];
const seenTexts = new Set();
let lastLength = 0;
while (postsData.length < 20) {
window.scrollTo(0, document.body.scrollHeight);
await new Promise(resolve => setTimeout(resolve, 2000)); // Wait for more posts to load