postaddictme/instagram-java-scraper

Can't get any data after login

Closed this issue · 1 comments

Hello,
I download the Instagram-java-scraper from this link with all it's dependency needed from this link
here
after that, I use this code to log in and get some media from a username inside a button function
` try {
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();
        
        Instagram instagram = new Instagram(httpClient);
        instagram.basePage();
        instagram.login("my user name", "my password");
        PageObject<Media> medias = instagram.getMedias("kevin", 1);
        jLabel2.setText("Url = " + medias.getNodes().get(0).getDisplayUrl());
    } catch (IOException ex) {
        Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
    }`

but i got this error from my netbeans IDE after i run it
`run:
--> GET https://www.instagram.com/ http/1.1
Host: www.instagram.com
Connection: Keep-Alive
Accept-Encoding: gzip
User-Agent: okhttp/3.2.0
--> END GET
<-- 200 OK https://www.instagram.com/ (947ms)
Content-Type: text/html
X-Frame-Options: SAMEORIGIN
Cache-Control: private, no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Vary: Cookie, Accept-Language, Accept-Encoding
Content-Language: en
Content-Encoding: gzip
Date: Wed, 04 Jul 2018 05:33:47 GMT
Strict-Transport-Security: max-age=86400
Set-Cookie: sessionid=""; Domain=.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
Set-Cookie: sessionid=""; Domain=.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
Set-Cookie: sessionid=""; Domain=.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
Set-Cookie: sessionid=""; Domain=.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
Set-Cookie: sessionid=""; Domain=.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
Set-Cookie: sessionid=""; Domain=.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
Set-Cookie: sessionid=""; Domain=.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
Set-Cookie: rur=FTW; Domain=.instagram.com; Path=/
Set-Cookie: csrftoken=sGQXx9W8LkmsRWojOnOetn2cMfzZHKzW; Domain=.instagram.com; expires=Wed, 03-Jul-2019 05:33:47 GMT; Max-Age=31449600; Path=/; Secure
Set-Cookie: mid=WzxcOwAEAAFiMvydbc3g_Xrd9k7b; Domain=.instagram.com; expires=Tue, 29-Jun-2038 05:33:47 GMT; Max-Age=630720000; Path=/
Set-Cookie: mcd=3; Domain=.instagram.com; Path=/
Connection: keep-alive
Content-Length: 6513
OkHttp-Sent-Millis: 1530682426312
OkHttp-Received-Millis: 1530682427250
<-- END HTTP (encoded body omitted)
--> POST https://www.instagram.com/accounts/login/ajax/ http/1.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 42
Referer: https://www.instagram.com/
X-CSRFToken: sGQXx9W8LkmsRWojOnOetn2cMfzZHKzW
Host: www.instagram.com
Connection: Keep-Alive
Accept-Encoding: gzip
Cookie: csrftoken=sGQXx9W8LkmsRWojOnOetn2cMfzZHKzW; mid=WzxcOwAEAAFiMvydbc3g_Xrd9k7b; rur=FTW; mcd=3
User-Agent: okhttp/3.2.0

username=username&password=password
--> END POST (42-byte body)
<-- 200 OK https://www.instagram.com/accounts/login/ajax/ (724ms)
Content-Type: application/json
Vary: Cookie, Accept-Language
Cache-Control: private, no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Content-Language: en
Date: Wed, 04 Jul 2018 05:33:48 GMT
Strict-Transport-Security: max-age=86400
Set-Cookie: target=""; Domain=instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
Set-Cookie: target=""; Domain=.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
Set-Cookie: target=""; Domain=i.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
Set-Cookie: target=""; Domain=.i.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
Set-Cookie: target=""; Domain=www.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
Set-Cookie: target=""; Domain=.www.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
Set-Cookie: target=""; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
Set-Cookie: csrftoken=oDdYMFiINK3rtNLmE0YYNL7SvO35AcVq; Domain=.instagram.com; expires=Wed, 03-Jul-2019 05:33:48 GMT; Max-Age=31449600; Path=/; Secure
Set-Cookie: rur=FTW; Domain=.instagram.com; Path=/
Set-Cookie: ds_user_id=8140736515; Domain=.instagram.com; expires=Tue, 02-Oct-2018 05:33:48 GMT; Max-Age=7776000; Path=/
Set-Cookie: sessionid=IGSCa819fdff5253e8a5c9c044980157b1f8ccc64f51bccfdb3f7d967a360846ba91%3AUlLkVJHBeWfS2plbq8e9EseRPFreJ2yT%3A%7B%22_auth_user_id%22%3A8140736515%2C%22_auth_user_backend%22%3A%22accounts.backends.CaseInsensitiveModelBackend%22%2C%22_auth_user_hash%22%3A%22%22%2C%22_platform%22%3A4%2C%22_token_ver%22%3A2%2C%22_token%22%3A%228140736515%3ACSkLrx5at7Sx2y0kucFw7tVQsYhCQBQN%3A7ecda006c44b6ef81cb39569183e2ce255d83f550e3cf347f20f1da93c7f695d%22%2C%22last_refreshed%22%3A1530682428.3057382107%7D; Domain=.instagram.com; expires=Tue, 02-Oct-2018 05:33:48 GMT; HttpOnly; Max-Age=7776000; Path=/; Secure
Connection: keep-alive
Content-Length: 100
OkHttp-Sent-Millis: 1530682427582
OkHttp-Received-Millis: 1530682428293

{"authenticated": true, "user": true, "userId": "8140736515", "oneTapPrompt": false, "status": "ok"}
<-- END HTTP (100-byte body)
--> GET https://www.instagram.com/kevin/?__a=1&max_id= http/1.1
Host: www.instagram.com
Connection: Keep-Alive
Accept-Encoding: gzip
Cookie: csrftoken=oDdYMFiINK3rtNLmE0YYNL7SvO35AcVq; sessionid=IGSCa819fdff5253e8a5c9c044980157b1f8ccc64f51bccfdb3f7d967a360846ba91%3AUlLkVJHBeWfS2plbq8e9EseRPFreJ2yT%3A%7B%22_auth_user_id%22%3A8140736515%2C%22_auth_user_backend%22%3A%22accounts.backends.CaseInsensitiveModelBackend%22%2C%22_auth_user_hash%22%3A%22%22%2C%22_platform%22%3A4%2C%22_token_ver%22%3A2%2C%22_token%22%3A%228140736515%3ACSkLrx5at7Sx2y0kucFw7tVQsYhCQBQN%3A7ecda006c44b6ef81cb39569183e2ce255d83f550e3cf347f20f1da93c7f695d%22%2C%22last_refreshed%22%3A1530682428.3057382107%7D; mid=WzxcOwAEAAFiMvydbc3g_Xrd9k7b; ds_user_id=8140736515; rur=FTW; mcd=3
User-Agent: okhttp/3.2.0
--> END GET
<-- 200 OK https://www.instagram.com/kevin/?__a=1&max_id= (558ms)
Content-Type: application/json
X-Frame-Options: SAMEORIGIN
x-robots-tag: noindex
Cache-Control: private, no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Vary: Cookie, Accept-Language, Accept-Encoding
Content-Language: en
Content-Encoding: gzip
Date: Wed, 04 Jul 2018 05:33:49 GMT
Strict-Transport-Security: max-age=86400
Set-Cookie: rur=FRC; Domain=.instagram.com; Path=/
Set-Cookie: csrftoken=oDdYMFiINK3rtNLmE0YYNL7SvO35AcVq; Domain=.instagram.com; expires=Wed, 03-Jul-2019 05:33:49 GMT; Max-Age=31449600; Path=/; Secure
Set-Cookie: ds_user_id=8140736515; Domain=.instagram.com; expires=Tue, 02-Oct-2018 05:33:49 GMT; Max-Age=7776000; Path=/
Set-Cookie: urlgen="{"time": 1530682428\054 "156.194.87.151": 8452}:1faaQH:8_R2daYjotrNGF_h1K8W-IzY--Y"; Domain=.instagram.com; Path=/
Connection: keep-alive
Content-Length: 8728
OkHttp-Sent-Millis: 1530682428512
OkHttp-Received-Millis: 1530682429074
<-- END HTTP (encoded body omitted)
[EL Warning]: moxy: 2018-07-04 07:33:49.715--MOXy BV: Facets generation could not be configured. EclipseLink's JavaModelInputImpl was not detected, instead JavaModelInput is of class: class org.eclipse.persistence.jaxb.javamodel.oxm.OXMJavaModelInputImpl
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: javax.xml.bind.UnmarshalException

  • with linked exception:
    [Exception [EclipseLink-25008] (Eclipse Persistence Services - 2.7.0.v20170811-d680af5): org.eclipse.persistence.exceptions.XMLMarshalException
    Exception Description: A descriptor with default root element logging_page_id was not found in the project]
    at me.postaddict.instagram.scraper.mapper.ModelMapper.mapObject(ModelMapper.java:156)
    at me.postaddict.instagram.scraper.mapper.ModelMapper.mapAccount(ModelMapper.java:39)
    at me.postaddict.instagram.scraper.request.GetAccountRequest.mapResponse(GetAccountRequest.java:39)
    at me.postaddict.instagram.scraper.request.GetAccountRequest.mapResponse(GetAccountRequest.java:13)
    at me.postaddict.instagram.scraper.request.PaginatedRequest.requestInstagramResult(PaginatedRequest.java:39)
    at me.postaddict.instagram.scraper.Instagram.getAccount(Instagram.java:95)
    at me.postaddict.instagram.scraper.Instagram.getMedias(Instagram.java:89)
    at MainWindow.jButton1ActionPerformed(MainWindow.java:112)
    at MainWindow.access$000(MainWindow.java:23)
    at MainWindow$1.actionPerformed(MainWindow.java:58)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6533)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6298)
    at java.awt.Container.processEvent(Container.java:2238)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2296)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4897)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4534)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4475)
    at java.awt.Container.dispatchEventImpl(Container.java:2282)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:733)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
    Caused by: javax.xml.bind.UnmarshalException
  • with linked exception:
    [Exception [EclipseLink-25008] (Eclipse Persistence Services - 2.7.0.v20170811-d680af5): org.eclipse.persistence.exceptions.XMLMarshalException
    Exception Description: A descriptor with default root element logging_page_id was not found in the project]
    at org.eclipse.persistence.jaxb.JAXBUnmarshaller.handleXMLMarshalException(JAXBUnmarshaller.java:1110)
    at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:172)
    at me.postaddict.instagram.scraper.mapper.ModelMapper.mapObject(ModelMapper.java:154)
    ... 45 more
    Caused by: Exception [EclipseLink-25008] (Eclipse Persistence Services - 2.7.0.v20170811-d680af5): org.eclipse.persistence.exceptions.XMLMarshalException
    Exception Description: A descriptor with default root element logging_page_id was not found in the project
    at org.eclipse.persistence.exceptions.XMLMarshalException.noDescriptorWithMatchingRootElement(XMLMarshalException.java:162)
    at org.eclipse.persistence.internal.oxm.record.SAXUnmarshallerHandler.startElement(SAXUnmarshallerHandler.java:309)
    at org.eclipse.persistence.internal.oxm.record.json.JsonStructureReader.parsePair(JsonStructureReader.java:455)
    at org.eclipse.persistence.internal.oxm.record.json.JsonStructureReader.parseRoot(JsonStructureReader.java:181)
    at org.eclipse.persistence.internal.oxm.record.json.JsonStructureReader.parse(JsonStructureReader.java:139)
    at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:938)
    at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:414)
    at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:390)
    at org.eclipse.persistence.internal.oxm.XMLUnmarshaller.unmarshal(XMLUnmarshaller.java:394)
    at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:156)
    ... 46 more
    `
    i changed for sure the user name and password to my own so any help please why i got this error
    Thanks in advance

I would recommend using Maven to handle dependencies in the future. As for your issue, I'm not familiar with this library so I can't help you much. It says IllegalArgumentException, so just from that I would assume you've given it bad user input somewhere. Although, most of the exception has something to do with Eclipse, so I would make sure you're on the latest version of Eclipse. Just make sure it's the one that says "for Java developers". I know it can be confusing sometimes.