Search in sources :

Example 6 with FakeBrowserInterceptor

use of me.postaddict.instagram.scraper.interceptor.FakeBrowserInterceptor in project instagram-java-scraper by postaddictme.

the class InstagramFactory method getAuthenticatedInstagramClient.

public static Instagram getAuthenticatedInstagramClient(String login, String password, String userAgent) throws IOException {
    OkHttpClient httpClient = new OkHttpClient.Builder().addInterceptor(new FakeBrowserInterceptor(userAgent)).addInterceptor(new ErrorInterceptor()).cookieJar(new DefaultCookieJar(new CookieHashSet())).build();
    Instagram client = new Instagram(httpClient);
    client.basePage();
    client.login(login, password);
    client.basePage();
    return client;
}
Also used : CookieHashSet(me.postaddict.instagram.scraper.cookie.CookieHashSet) OkHttpClient(okhttp3.OkHttpClient) ErrorInterceptor(me.postaddict.instagram.scraper.interceptor.ErrorInterceptor) DefaultCookieJar(me.postaddict.instagram.scraper.cookie.DefaultCookieJar) FakeBrowserInterceptor(me.postaddict.instagram.scraper.interceptor.FakeBrowserInterceptor)

Aggregations

ErrorInterceptor (me.postaddict.instagram.scraper.interceptor.ErrorInterceptor)6 FakeBrowserInterceptor (me.postaddict.instagram.scraper.interceptor.FakeBrowserInterceptor)6 OkHttpClient (okhttp3.OkHttpClient)6 CookieHashSet (me.postaddict.instagram.scraper.cookie.CookieHashSet)5 DefaultCookieJar (me.postaddict.instagram.scraper.cookie.DefaultCookieJar)5 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)5 BeforeClass (org.junit.BeforeClass)4 Test (org.junit.Test)1