forked from pjetcetal/clubhouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crawler.js
80 lines (65 loc) · 1.96 KB
/
crawler.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
71
72
73
74
75
76
77
78
79
80
'use strict'
require('dotenv-safe').config()
const { ClubhouseClient } = require('clubhouse-client')
const crawler = require('clubhouse-crawler')
// incremental crawler for the clubhouse social graph
async function main() {
const authToken = process.env.CLUBHOUSE_AUTH_TOKEN
const deviceId = process.env.CLUBHOUSE_DEVICE_ID
const userId = process.env.CLUBHOUSE_USER_ID
const clubhouse = new ClubhouseClient({
authToken,
deviceId,
userId
})
// const seedUserId = '4602198' // elon musk
const seedUserId = '76' // li jin
// const seedUserId = '104' // andrew chen
// const seedUserId = '2481724' // travis
// const seedUserId = '1968234007' // dawson
// const seedUserId = '275075562' // ron paul
// const seedUserId = '4' // clubhouse co-founder
const driver = crawler.driver()
const existingUserPendingIds = new Set()
try {
let session
try {
session = driver.session({ defaultAccessMode: 'READ' })
const numUserNodes = (await crawler.getNumUsers(session)).records[0]?.get(
0
)
const numFollowerRelationships = (
await crawler.getNumFollowers(session)
).records[0]?.get(0)
const numInviteRelationships = (
await crawler.getNumUserInvites(session)
).records[0]?.get(0)
const seedUserIds = (
await crawler.getSeedUsers(session)
).records.map((record) => record.get(0))
for (const userId of seedUserIds) {
existingUserPendingIds.add(userId)
}
clubhouse.log('crawling', {
numUserNodes,
numFollowerRelationships,
numInviteRelationships,
seedUserIds
})
} finally {
await session.close()
}
const socialGraph = await crawler.crawlSocialGraph(clubhouse, seedUserId, {
maxUsers: 100000,
crawlFollowers: true,
crawlInvites: true,
existingUserPendingIds,
driver
})
} finally {
await driver.close()
}
}
main().catch((err) => {
console.error(err)
})