Skip to content

Instantly share code, notes, and snippets.

@davidsaccavino
Last active October 25, 2018 09:24
Show Gist options
  • Save davidsaccavino/3f3c1165132ca8a2ec2ccffbe2f7f276 to your computer and use it in GitHub Desktop.
Save davidsaccavino/3f3c1165132ca8a2ec2ccffbe2f7f276 to your computer and use it in GitHub Desktop.
const puppeteer = require("puppeteer");
// const search = /c(omputer)*\s*s(cience)*|s(oftware)*[\s|w]+[e(ngineer)*|dev(eloper)*]*|full\s?stack|dev(eloper)*|web|Human Resources|H\s?R|engineer|dropbox|google|yelp|twitter|f(ace)b(ook)|two sigma|github|y(ou)t(ube)|admin|software|research/i;
async function invite() {
const browser = await puppeteer.launch({ headless: false });
let page = await browser.newPage();
await page
.goto("https://www.linkedin.com/")
.then(async () => {
await page.type("#login-email", "user", {
delay: 20 * Math.random()
});
})
.then(async () => {
await page.type("#login-password", "pass", {
delay: 20 * Math.random()
});
})
.then(async () => {
await page.click("#login-submit");
})
.then(async () => {
await page.waitForNavigation();
await page.goto("https://www.linkedin.com/mynetwork/");
connect(page);
});
}
async function connect(page) {
setInterval(async () => {
if (Math.random() * 1 >= 0.35) {
await page.waitFor(1);
console.log("sent");
await page.click("button.button-secondary-small");
}
}, 1000);
// page.waitFor(1);
// page
// .evaluate(
// () =>
// document.querySelector(
// "span.pymk-card__occupation.t-12.t-black--light.t-normal"
// ).textContent
// )
// .then(async text => {
// if (text.match(search)) {
// await page.waitFor(2);
// page.click("button.button-secondary-small");
// } else {
// await page.hover("li.mn-pymk-list__card.display-flex.flex-column");
// page.click("button.pymk-card__close-btn");
// }
// });
}
invite();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment