-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
49 lines (40 loc) · 1.34 KB
/
main.lua
File metadata and controls
49 lines (40 loc) · 1.34 KB
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
local copas = require("copas")
local t_utils = require("util/table_utils")
local scraping = require("util/scraping")
local username = arg[1]
io.stdout:flush()
local function Main()
if username == nil then
print("Usage: " .. arg[0] .. " <username>")
return
end
print("Target: "..username)
print("Scraping... (can take up to a couple minutes on big profiles due to shit multithreading)")
local emails = scraping.CrawlEmailsFromGithubProfile(username)
local collection = {}
-- Collect All Emails From All Repositories
if emails then
for _, emailsInCurrentRepository in ipairs(emails) do
for _, v in ipairs(emailsInCurrentRepository) do
table.insert(collection, v)
end
end
end
-- Calculate Confidence score for all emails
local confidenceArray = t_utils.calculateConfidence(collection)
local sortedConfidence = {}
-- Copy emails into sorted confidence for sorting
for email, _ in pairs(confidenceArray) do
table.insert(sortedConfidence, email)
end
-- Remove duplicates, sort and print out the result
table.sort(sortedConfidence, function(a, b)
return confidenceArray[a] > confidenceArray[b]
end)
local deduplicatedEmails = t_utils.DeduplicateTable(collection)
for idx, email in ipairs(sortedConfidence) do
print(email.." "..confidenceArray[email] .. "%".." confidence")
end
end
copas.addthread(Main)
copas.loop()