Created
February 3, 2021 15:51
-
-
Save papalardo/f2e8c0eec85c1566eee2a8912d766660 to your computer and use it in GitHub Desktop.
This file contains 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 IgApiClient = require('instagram-private-api').IgApiClient; | |
const ig = new IgApiClient(); | |
// Suas credenciais (para algumas ações, inclusive buscar imagens, é obrigatório) | |
const userName = 'papalardo'; | |
const userPassword = ''; | |
// Para buscar o id do usuário acesse: https://codeofaninja.com/tools/find-instagram-user-id/ | |
const userId = '40266287952'; | |
// Gera estado - Obrigatório | |
ig.state.generateDevice(userName); | |
(async () => { | |
// Executa os requests pré-login. É recomendado | |
await ig.simulate.preLoginFlow(); | |
// Realiza o login | |
await ig.account.login(userName, userPassword); | |
// Cria a instancia do feed do usuário | |
const userFeed = ig.feed.user(userId); | |
// Pega a primeira página de posts | |
const myPostsFirstPage = await userFeed.items(); | |
// Pega o primeiro post do feed | |
const firstPost = myPostsFirstPage[0]; | |
// Imagens do post | |
console.log(firstPost.image_versions2.candidates) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment