Search code examples
javascripthtmlimdb

Add the IMBD rating to my web site / HTML


I'm using HTML to create a film review site and trying to add the IMDB rating.

I'm using this code :

<!DOCTYPE html>
<html>
<div class="rating-row" itemprop="aggregateRating" itemscope 
    itemtype="http://schema.org/AggregateRating">
    <a class="icon" href="https://www.imdb.com/title/tt7126948/" title="IMDb 
        Rating" target="_blank">
        <img src="https://yts.mx/assets/images/website/logo-imdb.svg" alt="IMDb Rating" />  
    </a>
    <span itemprop="ratingValue">5.5</span>
    <span itemprop="bestRating" style="display: none;">10</span>
    <span itemprop="ratingCount" style="display: none;">135549</span>
    <span class="hidden-xs icon-star"></span>
</div>
</html>

It gives me the IMDB logo and the rating next to it, but I don't know how to make the rating auto-refresh when its value changes on the IMDB website.

In the code I put the value 5.5 manually. Is there a way to automize the process?

PS: I'm new to HTML, I just started using it.


Solution

  • You can't automatize it using only HTML, you will need to use PHP or Javascript (AJAX) and request directly to the IMDB website API. So whenever you're accessing the webpage you ask to the website What is the rating ? the IMDB API send you the current rating and you display the value into your HTML.