-
Notifications
You must be signed in to change notification settings - Fork 20
/
parse.js
70 lines (63 loc) · 1.63 KB
/
parse.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
62
63
64
65
66
67
68
69
70
const fs = require("fs");
const statuses = require("./statuses2020-02-15T06:11:23.438Z.json"); // Change accordingly
const { getTweetText, isRetweet } = require("./util/tweets");
console.log(statuses.length);
const getEducation = tweetText =>
tweetText
.split("🏫")[1]
.split("\n")[0]
.replace(":", "")
.trim();
const getExperience = tweetText =>
tweetText
.split("⏳")[1]
.split("\n")[0]
.replace(":", "")
.trim();
const getLevel = tweetText => {
try {
return tweetText
.split("🏷")[1]
.split("\n")[0]
.replace(":", "")
.trim();
} catch (err) {
return "";
}
};
const getLocation = tweetText =>
tweetText
.split("🌎")[1]
.split("\n")[0]
.replace(":", "")
.trim();
const getSalary = tweetText =>
tweetText
.split("💸")[1]
.split("\n")[0]
.split("https://")[0]
.replace(":", "")
.trim();
const csvHeaders = `url,tweetId,screenName,name,bio,followersCount,education,experience,level,location,salary`;
const csv = [csvHeaders];
for (const tweet of statuses.filter(t => !isRetweet(t))) {
const tweetText = getTweetText(tweet);
const line = [
`https://twitter.com/${tweet.user.id_str}/status/${tweet.id_str}`,
tweet.id_str,
tweet.user.screen_name,
tweet.user.name,
tweet.user.description,
tweet.user.followers_count,
getEducation(tweetText),
getExperience(tweetText),
getLevel(tweetText),
getLocation(tweetText),
getSalary(tweetText)
]
.map(str => `"${str}"`)
.join(",");
console.log(line);
csv.push(line);
}
fs.writeFileSync(`${new Date().toISOString()}.csv`, csv.join("\n"));