Find out the social startics at one place
.then(data => {
const statsDisplay = document.getElementById('statsDisplay');
const followerCount = data.graphql.user.edge_followed_by.count;
statsDisplay.innerHTML += `
Instagram Followers:
${followerCount}
`;
})
.catch(error => console.error('Error fetching Instagram stats:', error));
}
function getFacebookStats() {
const facebookUrl = document.getElementById('facebookUrl').value;
fetch(`https://www.facebook.com/${extractFacebookPageId(facebookUrl)}`)
.then(response => response.text())
.then(html => {
const followerCount = extractFacebookFollowers(html);
const statsDisplay = document.getElementById('statsDisplay');
statsDisplay.innerHTML += `
Facebook Followers:
${followerCount}
`;
})
.catch(error => console.error('Error fetching Facebook stats:', error));
}
function extractInstagramUsername(url) {
const regex = /(?:https?:\/\/)?(?:www\.)?instagram\.com\/([^\/\?\&]+)/;
const match = url.match(regex);
return match ? match[1] : null;
}
function extractFacebookPageId(url) {
const regex = /(?:https?:\/\/)?(?:www\.)?facebook\.com\/([^\/\?\&]+)/;
const match = url.match(regex);
return match ? match[1] : null;
}
function extractFacebookFollowers(html) {
const followerCountMatch = html.match(/"follower_count":"(\d+)"/);
return followerCountMatch ? followerCountMatch[1] : 'N/A';
}
]]>
0 Response to "Find out the social startics at one place"
Post a Comment