Last active
April 2, 2022 17:16
-
-
Save laranicolas/8e58d13382d36b0138813dc9b17bef2c to your computer and use it in GitHub Desktop.
Linkedin scraper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.scrollTo(0,document.body.scrollHeight); | |
setTimeout(function(){ | |
const copyToClipboard = str => { | |
const el = document.createElement('textarea'); | |
el.value = str; | |
el.setAttribute('readonly', ''); | |
el.style.position = 'absolute'; | |
el.style.left = '-9999px'; | |
document.body.appendChild(el); | |
el.select(); | |
document.execCommand('copy'); | |
document.body.removeChild(el); | |
}; | |
results = Array.from([...document.querySelectorAll('#search-results-container .artdeco-list__item')].map( | |
function(container, index) { | |
let title, titleLnk, subTitle, caption, subTitleAnchore, subTitleAnchoreLnk = "" | |
if (container.querySelector('.artdeco-entity-lockup__title a')) { | |
title = container.querySelector('.artdeco-entity-lockup__title a').innerText | |
} | |
if (container.querySelector('.artdeco-entity-lockup__title a')) { | |
titleLnk = container.querySelector('.artdeco-entity-lockup__title a').href | |
} | |
if (container.querySelector('.artdeco-entity-lockup__subtitle span')) { | |
subTitle = container.querySelector('.artdeco-entity-lockup__subtitle span').innerText | |
} | |
if (container.querySelector('.artdeco-entity-lockup__caption span')) { | |
caption = container.querySelector('.artdeco-entity-lockup__caption span').innerText | |
} | |
if (container.querySelector('.artdeco-entity-lockup__subtitle a')) { | |
subTitleAnchore = container.querySelector('.artdeco-entity-lockup__subtitle a').innerText | |
} | |
if (container.querySelector('.artdeco-entity-lockup__subtitle a')) { | |
subTitleAnchoreLnk = container.querySelector('.artdeco-entity-lockup__subtitle a').href | |
} | |
return ( | |
'"' + title + '"' + "\t" + | |
'"' + titleLnk + '"' + "\t" + | |
'"' + subTitle + '"' + "\t" + | |
'"' + caption + '"' + "\t" + | |
'"' + subTitleAnchore + '"' + "\t" + | |
'"' + subTitleAnchoreLnk + '"' | |
) | |
} | |
)).join("\r\n") | |
console.log(results) | |
copyToClipboard(results) | |
}, 3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment