Skip to content

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

Notifications You must be signed in to change notification settings

wendongbao/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

How to use release version of Instagram Java scraper

TODO documentation/release

mvnrepository

jcenter

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

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 without any authorization

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%