-
Notifications
You must be signed in to change notification settings - Fork 0
/
getEmailsFromToofr.js
61 lines (52 loc) · 1.56 KB
/
getEmailsFromToofr.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const axios = require("axios");
const { writeEmailsToFile } = require("./utils");
const { postDataToAppsScript } = require("./utils");
let url = "https://www.findemails.com/api/v1/guess_email.json";
let key = "2491d6a5b8daba96163db50457f6e1bc";
const getEmails = async (googleData, scriptUrl) => {
//console.log(first_name,last_name,company_name);
// if (!first_name || !last_name || !company_name) {
// return "";
// }
for (let index = 0; index < googleData.length; index++) {
let dataGoogle = [];
const el = googleData[index];
//console.log("INDEX", index, el);
dataGoogle.push(
el.firstName,
el.lastName,
el.vertical,
el.companyName,
el.website,
el.location,
el.country,
el.url,
el.address
);
await axios
.post(url, {
first_name: el.firstName,
last_name: el.lastName,
company_name: el.website,
key
})
.then(function(response) {
//console.log("enter");
let data = Object.values(response.data).slice(0, 3);
//console.log(data);
data.forEach(element => {
dataGoogle.push(element.confidence, element.email);
});
console.log("DATA GOOGLE", [dataGoogle]);
postDataToAppsScript(scriptUrl, [dataGoogle], "emailsToofr");
return dataGoogle;
//writeEmailsToFile(emails);
})
.catch(function(error) {
console.log(error.message);
return null;
});
}
};
//getEmails("Travis", "Benton", "mydomain");
module.exports.getEmailsFromToofr = getEmails;