İnstagram için profil fotoğrafı indirme veya görüntülemek için forumda script arayanlar oluyor denk geldim kaç kere bende size nodejs ile indirebileceğiniz basic bir JS bırakıyorum
tek yapmanız gereken nodejs kurmanız ve index'i çalıştırmanız için gereken paketleri kurmak.
not: indirdiğiniz fotoğraflar "foto" klasörüne indirilecektir bilginize.
tek yapmanız gereken nodejs kurmanız ve index'i çalıştırmanız için gereken paketleri kurmak.
not: indirdiğiniz fotoğraflar "foto" klasörüne indirilecektir bilginize.
const axios = require('axios');
const readline = require('readline');
const fs = require('fs');
const path = require('path');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('Please enter the Instagram username: ', (username) => {
const apiUrl = `https://i.instagram.com/api/v1/users/web_profile_info/?username=${username}`;
const userAgent = "Instagram 337.0.0.0.77 Android (28/9; 420dpi; 1080x1920; samsung; SM-G611F; on7xreflte; samsungexynos7870; en_US; 493419337)";
axios.get(apiUrl, {
headers: {
'User-Agent': userAgent
}
})
.then(response => {
const profilePicUrlHD = response.data.data.user.profile_pic_url_hd;
const fileName = `${username}.jpg`;
const folderPath = path.join(__dirname, 'foto');
if (!fs.existsSync(folderPath)) {
fs.mkdirSync(folderPath);
}
axios({
url: profilePicUrlHD,
method: 'GET',
responseType: 'stream'
})
.then(response => {
const filePath = path.join(folderPath, fileName);
response.data.pipe(fs.createWriteStream(filePath));
console.log(`Profile picture successfully saved: ${fileName}`);
})
.catch(error => {
console.error('Error while downloading the image:', error.message);
});
})
.catch(error => {
console.error('User not found or error occurred.');
})
.finally(() => {
rl.close();
});
});