Skip to content

Instantly share code, notes, and snippets.

@papalardo
Created February 3, 2021 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save papalardo/f2e8c0eec85c1566eee2a8912d766660 to your computer and use it in GitHub Desktop.
Save papalardo/f2e8c0eec85c1566eee2a8912d766660 to your computer and use it in GitHub Desktop.
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