How do I pull elements from another page?

Asked

Viewed 106 times

0

I am working on a script that needs to remove elements from a web page and add some text information to mine. I need you to script me from IMDB the description of an anime, how can I do it?

Example: through a link like this http://www.imdb.com/title/tt0433740/?ref_=nv_sr_1, I could add things in my html like, the main image, the description and the note.

  • 2

    Just a doubt, imdb allows this to be done?

  • 1

    Script to run in a browser? Basically, you can’t. Browsers normally prevent XSS unless you use AJAX and Access-Control-Allow-Origin.

  • 2

    like @Ls_dev and @diegofm comentarm, it’s not right to take information like this from imdb and it won’t work from the browser in a simple way. Why don’t you use the api imdb? It allows you to query and treat the results, so you can show your site the way you want, including images. Take a look here: https://www.themoviedb.org/documentation/api

  • You can do this on a server level. A wget or equivalent pulls the page, then it becomes automated text editing. Then, after treating the text the way you want, return your editing to the browser

  • Look, it’s not interesting that you do this way for 2 reasons 1 - Loading your site would be stuck until you download the IMDB content and reinsert it 2 - IMDB content is not static, it changes constantly. If they change a tag, you can mess up your entire site. As mentioned above, or you use the API and grab JSON. or you run a Rawler from time to time that downloads the imdb information to a database and from that database, you fill in your website. This is gonna be hard work, but it works.

1 answer

0

Imdb has a API and you can get the information of any title by her
API: http://www.omdbapi.com/

Javascript function to get the information you can do this with PHP tbm

function GetImdb(titulo) {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
       var resutado = JSON.parse(this.responseText);
       alert(resutado.Poster);
    }
  };
  xhttp.open("GET", "http://www.omdbapi.com/?t=" + titulo, true);
  xhttp.send();
}

GetImdb("Justice+League");
  • "This site is not endorsed by or affiliated with Imdb.com." in www.omdbapi.com

Browser other questions tagged

You are not signed in. Login or sign up in order to post.