Search in sources :

Example 1 with UserAgentInterceptor

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

the class AnonymousInstaTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    OkHttpClient httpClient = new OkHttpClient.Builder().addNetworkInterceptor(loggingInterceptor).addInterceptor(new UserAgentInterceptor(UserAgents.OSX_CHROME)).addInterceptor(new ErrorInterceptor()).cookieJar(new DefaultCookieJar(new CookieHashSet())).build();
    client = new Instagram(httpClient);
    client.basePage();
}
Also used : CookieHashSet(me.postaddict.instagram.scraper.cookie.CookieHashSet) OkHttpClient(okhttp3.OkHttpClient) ErrorInterceptor(me.postaddict.instagram.scraper.interceptor.ErrorInterceptor) UserAgentInterceptor(me.postaddict.instagram.scraper.interceptor.UserAgentInterceptor) DefaultCookieJar(me.postaddict.instagram.scraper.cookie.DefaultCookieJar) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) BeforeClass(org.junit.BeforeClass)

Example 2 with UserAgentInterceptor

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

the class AuthenticatedInstaTest method testLoginWithInvalidCredentials.

@Test(expected = InstagramAuthException.class)
public void testLoginWithInvalidCredentials() throws Exception {
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.HEADERS);
    OkHttpClient httpClient = new OkHttpClient.Builder().addNetworkInterceptor(loggingInterceptor).addInterceptor(new UserAgentInterceptor(UserAgents.OSX_CHROME)).addInterceptor(new ErrorInterceptor()).cookieJar(new DefaultCookieJar(new CookieHashSet())).build();
    Instagram instagramClient = new Instagram(httpClient);
    instagramClient.basePage();
    instagramClient.login("1", "2");
}
Also used : CookieHashSet(me.postaddict.instagram.scraper.cookie.CookieHashSet) OkHttpClient(okhttp3.OkHttpClient) ErrorInterceptor(me.postaddict.instagram.scraper.interceptor.ErrorInterceptor) UserAgentInterceptor(me.postaddict.instagram.scraper.interceptor.UserAgentInterceptor) DefaultCookieJar(me.postaddict.instagram.scraper.cookie.DefaultCookieJar) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Test(org.junit.Test)

Example 3 with UserAgentInterceptor

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

the class AuthenticatedInstaTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    Credentials credentials = new Credentials();
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.HEADERS);
    OkHttpClient httpClient = new OkHttpClient.Builder().addNetworkInterceptor(loggingInterceptor).addInterceptor(new UserAgentInterceptor(UserAgents.OSX_CHROME)).addInterceptor(new ErrorInterceptor()).cookieJar(new DefaultCookieJar(new CookieHashSet())).build();
    client = new Instagram(httpClient);
    client.basePage();
    client.login(credentials.getLogin(), credentials.getPassword());
    client.basePage();
}
Also used : CookieHashSet(me.postaddict.instagram.scraper.cookie.CookieHashSet) OkHttpClient(okhttp3.OkHttpClient) ErrorInterceptor(me.postaddict.instagram.scraper.interceptor.ErrorInterceptor) UserAgentInterceptor(me.postaddict.instagram.scraper.interceptor.UserAgentInterceptor) DefaultCookieJar(me.postaddict.instagram.scraper.cookie.DefaultCookieJar) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) BeforeClass(org.junit.BeforeClass)

Example 4 with UserAgentInterceptor

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

the class MultiThreadTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    OkHttpClient httpClient = new OkHttpClient.Builder().addNetworkInterceptor(loggingInterceptor).addInterceptor(new UserAgentInterceptor(UserAgents.OSX_CHROME)).addInterceptor(new ErrorInterceptor()).cookieJar(new DefaultCookieJar(new CookieHashSet())).build();
    client = new Instagram(httpClient);
    client.basePage();
}
Also used : CookieHashSet(me.postaddict.instagram.scraper.cookie.CookieHashSet) OkHttpClient(okhttp3.OkHttpClient) ErrorInterceptor(me.postaddict.instagram.scraper.interceptor.ErrorInterceptor) UserAgentInterceptor(me.postaddict.instagram.scraper.interceptor.UserAgentInterceptor) DefaultCookieJar(me.postaddict.instagram.scraper.cookie.DefaultCookieJar) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) BeforeClass(org.junit.BeforeClass)

Example 5 with UserAgentInterceptor

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

the class StatelessInstaTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.HEADERS);
    OkHttpClient httpClient = new OkHttpClient.Builder().addNetworkInterceptor(loggingInterceptor).addInterceptor(new UserAgentInterceptor(UserAgents.OSX_CHROME)).addInterceptor(new ErrorInterceptor()).build();
    client = new Instagram(httpClient);
    client.basePage();
}
Also used : OkHttpClient(okhttp3.OkHttpClient) ErrorInterceptor(me.postaddict.instagram.scraper.interceptor.ErrorInterceptor) UserAgentInterceptor(me.postaddict.instagram.scraper.interceptor.UserAgentInterceptor) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) BeforeClass(org.junit.BeforeClass)

Aggregations

ErrorInterceptor (me.postaddict.instagram.scraper.interceptor.ErrorInterceptor)6 UserAgentInterceptor (me.postaddict.instagram.scraper.interceptor.UserAgentInterceptor)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