OP-Engineering / link-preview-js

⛓ Extract web links information: title, description, images, videos, etc. [via OpenGraph], runs on mobiles and node.
MIT License
770 stars 124 forks source link

[Bug] Instagram links have "Login * Instagram" without an image or description when previously they were showing both image and description #89

Closed tennispro7797 closed 3 years ago

tennispro7797 commented 3 years ago

Describe the bug This library was working great yesterday when I used an IG link to a public profile like https://www.instagram.com/p/CJ_qZYbF0A-/?igshid=1ge8l6mihp1xi, but today when I'm doing that, this is the data that is being returned

Object {
  "contentType": "text/html",
  "description": "Welcome back to Instagram. Sign in to check out what your friends, family & interests have been capturing & sharing around the world.",
  "favicons": Array [
    "https://www.instagram.com/static/images/ico/favicon-192.png/68d99ba29cc8.png",
    "https://www.instagram.com/static/images/ico/favicon.ico/36b3ee2d91ed.ico",
  ],
  "images": Array [],
  "mediaType": "website",
  "siteName": undefined,
  "title": "
Login • Instagram
",
  "url": "https://www.instagram.com/accounts/login/",
  "videos": Array [],
}

Expected behavior For another link in the same public profile, https://www.instagram.com/reel/CKEzTVbFo_t/?igshid=rk2gmwdkxxqw, the data is returned as expected, with an image and description:

Object {
  "contentType": "text/html",
  "description": "feedmi_ • Original Audio",
  "favicons": Array [
    "https://www.instagram.com/static/images/ico/favicon-192.png/68d99ba29cc8.png",
    "https://www.instagram.com/static/images/ico/favicon.ico/36b3ee2d91ed.ico",
  ],
  "images": Array [
    "https://scontent-dfw5-1.cdninstagram.com/v/t51.2885-15/e35/139016296_454367992259185_875994249021980597_n.jpg?_nc_ht=scontent-dfw5-1.cdninstagram.com&_nc_cat=101&_nc_ohc=KYNMB1IkUFkAX-MwYmA&tp=1&oh=356ad26b1e9c84194b8bacbc28b0ce2f&oe=60322F73",
  ],
  "mediaType": "video",
  "siteName": "Instagram",
  "title": "feedmi_ on Instagram: Extra thick & gooey CEREAL COOKIES ft @heb’s Cerealology Fig & Nut Crunch cereal! 🍪 Did a little experimenting in the kitchen & these…",
  "url": "https://www.instagram.com/reel/CKEzTVbFo_t/?igshid=1mczqfx4hv5vk",
  "videos": Array [
    Object {
      "height": "1137",
      "secureUrl": "https://scontent-dfw5-2.cdninstagram.com/v/t50.2886-16/139529888_338872643819508_5061516141997524761_n.mp4?_nc_ht=scontent-dfw5-2.cdninstagram.com&_nc_cat=100&_nc_ohc=FUixYdUpUQsAX_41KVp&oe=60329B42&oh=eded19a7254e9175758248a25efe1160",
      "type": "video/mp4",
      "url": "https://scontent-dfw5-2.cdninstagram.com/v/t50.2886-16/139529888_338872643819508_5061516141997524761_n.mp4?_nc_ht=scontent-dfw5-2.cdninstagram.com&_nc_cat=100&_nc_ohc=FUixYdUpUQsAX_41KVp&oe=60329B42&oh=eded19a7254e9175758248a25efe1160",
      "width": "640",
    },
  ],
}

Smartphone (please complete the following information):

ospfranco commented 3 years ago

This is not a problem with the library (the fact that the second link returns data confirms it) but some Instagram logic redirecting the request as an unauthenticated user and trying to force a registering step

You might try to change the user agent but I cannot fix Instagram 😜