Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Instagram Java Scraper. Get account information, photos, videos and comments.

Notifications You must be signed in to change notification settings

evosystem-jp/instagram-java-scraper

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instagram Java scraper

Instagram Java Scraper. Get account information, photos and videos without any authorization.

Get account by username

Instagram instagram = new Instagram(httpClient);
Account account = instagram.getAccountByUsername("kevin");
System.out.println(account.getMedia().getCount());

Get account by account id

Instagram instagram = new Instagram(httpClient);
Account account = instagram.getAccountById(3);
System.out.println(account.getFullName());

Get account medias

PageObject<Media> medias = instagram.getMedias("durov", 1);
System.out.println(medias.getNodes().get(0).getDisplayUrl());

Get media by code

Media media = instagram.getMediaByUrl("BGY0zB4r7X2");
System.out.println(media.getOwner().getUsername());

Get media by url

Media media = instagram.getMediaByUrl("https://www.instagram.com/p/BGY0zB4r7X2");
System.out.println(media.getOwner().getUsername());

Convert media id to shortcode

MediaUtil.getCodeFromId("1270593720437182847_3");
// OR
MediaUtil.getCodeFromId("1270593720437182847");
// Output: BGiDkHAgBF_
// So you can do like this: instagram.com/p/BGiDkHAgBF_

Convert shortcode to media id

MediaUtil.getIdFromCode('BGiDkHAgBF_');
// Output: 1270593720437182847

If you use this library in your project and want to help us

  • Mark project repository by star on github
  • Make pull request with bug fix
  • Follow project contributors

How to use release version of Instagram Java scraper

Released as com.github.igor-suhorukov:instagramscraper:2.2 into maven central

How to use development version of Instagram Java scraper

Read more info on jitpack page of project. Open "Commit" tab and select revision by commit hash. Just open Gradle or Maven tab copy artifact info and place it with dendency management repository in your project build configuration

IDE lombok plugin

Project Lombok is a java library that automatically plugs into your editor and build tools, spicing up your java. Never write another getter or equals method again.

If instagram-java-scraper IDE compilation failing because of all the missing getters/setters. Just setup lombok plugin for IntelliJ Idea, Eclipse or Netbeans

Setup http client to handle errors, log response and store cookies

HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);

OkHttpClient httpClient = new OkHttpClient.Builder()
        .addNetworkInterceptor(loggingInterceptor)
        .addInterceptor(new ErrorInterceptor())
        .cookieJar(new DefaultCookieJar(new CookieHashSet()))
        .build();

Other

PHP library: https://github.com/postaddictme/instagram-php-scraper

About

Instagram Java Scraper. Get account information, photos, videos and comments.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%