Created
October 1, 2024 20:00
-
-
Save vittau/a65c5ee99e28d44c98b2bc219e8d3b93 to your computer and use it in GitHub Desktop.
Users who don't follow back on Instagram (use exported data as JSON)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
// Function to read JSON files | |
function readJsonFile(filePath) { | |
return new Promise((resolve, reject) => { | |
fs.readFile(filePath, "utf8", (err, data) => { | |
if (err) { | |
reject(err); | |
} else { | |
resolve(JSON.parse(data)); | |
} | |
}); | |
}); | |
} | |
// Function to find the set difference | |
function findSetDifference(following, followers) { | |
const followingSet = new Set(following); | |
const followersSet = new Set(followers); | |
return followingSet.difference(followersSet); | |
} | |
// Main function to read files and print the set difference | |
async function main() { | |
try { | |
const fileFollowing = await readJsonFile("following.json").relationships_following; | |
const fileFollowers = await readJsonFile("followers_1.json"); | |
const following = fileFollowing.map((i) => i.string_list_data[0].value); | |
const followers = fileFollowers.map((i) => i.string_list_data[0].value); | |
const difference = findSetDifference(following, followers); | |
console.log('People in "following" not in "followers":', difference); | |
} catch (error) { | |
console.error("Error reading files:", error); | |
} | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment