[ESP-ENG] Obtén datos del sitio web IMDb con Python || Get data from the IMDb web site with Python

in GEMS4 years ago

preview.png

Imagen diseñada con snappa || Image designed with snappa

Hola Hivers. Buen día. He creado un nuevo script para usarlo en IMDB, IMDB es un sitio que almacena información sobre películas, es un sitio muy popular en él se puede consultar los estrenos más recientes así como también las películas más vistas o populares que realizan los usuarios en dicho sitio web. Para efectos prácticos, nuevamente utilicé las librerías httpx y selectolax, para obtener el título, año y calificación de varias películas en la sección de "Películas más populares".

Bueno, sin más preambulos les dejaré el script con sus respectivos resultados. Espero que lo disfruten, este no es más que otra publicación para mostrarle la utilidad y el alcance de estas librerías en otro de los muchos sitios alojados en el Internet.

Hello Hivers. Good morning. I have created a new script to use it in IMDB, IMDB is a site that stores information about movies, it is a very popular site where you can check the most recent releases as well as the most viewed or popular movies made by users on that website. For practical purposes, again I used the httpx and selectolax libraries, to obtain the title, year and rating of several movies in the "Most popular movies" section.

Well, without further ado, I'll leave you the script with its respective results. I hope you enjoy it, this is just another post to show you the usefulness and scope of these libraries in another of the many sites hosted on the Internet.

import httpx
from selectolax.parser import HTMLParser
page= 'https://www.imdb.com/chart/moviemeter/'
client = httpx.Client()
imdb =  client.get(page)
parse= imdb.text
data_links = HTMLParser(parse)
search=data_links.css_first('tbody.lister-list')
title=search.css('td.titleColumn > a')
year=search.css('td.titleColumn > span')
rating=search.css('td.ratingColumn.imdbRating > strong')
for t,y,r in zip(title,year,rating):
    dt=t.text(strip=True)
    dy=y.text(strip=True)
    dr=r.text(strip=True)
    print({'title':dt,
            'year':dy,
            'rating':dr})

result.png

result II.png


Text translated by DeepL

Sort:  

Hace un tiempo estaba buscando algo asi, muchas gracias por la informacion bro. No sabia que podia usar Python asi.

Me alegro de que esta información haya sido útil para usted, gracias por tu visita. Espero verte otra vez por acá. :)

Congratulations @pynomiems! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s):

You published more than 30 posts.
Your next target is to reach 40 posts.
You distributed more than 500 upvotes.
Your next target is to reach 600 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Check out the last post from @hivebuzz:

The fourth edition of Hive Power Up Month started today. Don't miss it!
Hive Power Up Day - April 1st 2022
Support the HiveBuzz project. Vote for our proposal!