Results 1 to 2 of 2

Thread: Help me get this image

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2022
    Posts
    2

    Question Help me get this image

    So I'm trying to extract a picture from the website https://libremdb.pussthecat.org/ (witch is a site for privacy, taking its information from IMDb)
    I use HtmlAgilityPack to extract the image of the movie or show, witch i successfully did with https://www.themoviedb.org/. My problem right now is that i can't get the image with pussthecat (I tried to use IMDb but was unable to get the image because its harder (at least for me)) because the Xpath I'm retrieving is the wrong one but there are multiple images in there. The URL i get is the one without width and height (witch is necessary for the image) i know its hard to understand so i will give you some example links and Xpath:


    Xpath: /html/body/div/main/section[1]/div[1]/img
    Random movie Image: Go to https://libremdb.pussthecat.org/ search for any movie right click the image and open in a new tab.

    Right now i cant think of anything else but please tell me in the comments.
    Last edited by Lordloser; Aug 21st, 2024 at 11:22 AM. Reason: Fixed the title

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,370

    Re: Help me get this image

    Looking at the source code, it appears as though they provide the JSON that powers the page in the document via the #__NEXT_DATA__ script element.

    So for example, I can do this from my console:
    1. Get the script tag by calling
      Code:
      document.querySelector('#__NEXT_DATA__')
    2. Get the JSON literal by calling
      Code:
      JSON.parse(document.querySelector('#__NEXT_DATA__').innerText)
    3. Traverse the JSON by accessing
      Code:
      props.pageProps.data.results.titles[0].image


    So to do this from VB.NET, you would use your HtmlAgilityPack to parse the HTML and select the #__NEXT_DATA__ script element. Use JSON.NET or Newtonsoft.JSON to parse the JSON literal to a strongly typed class. And then finally access the property via the path above.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width