Created
May 27, 2025 11:40
-
-
Save MrSmoke/b36328716ae2a64265d3e0c982341b7a to your computer and use it in GitHub Desktop.
IMDB Top250 Scrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function () { | |
| let output = 'Ranking,Name,Year,Duration,Runtime,Rating,Star Rating\n'; | |
| document | |
| .querySelectorAll('.ipc-metadata-list-summary-item') | |
| .forEach(y => { | |
| const heading = y.querySelector('h3').innerText.split(/^(\d+). /).slice(1); | |
| const metadata = y.querySelector('.cli-title-metadata').children; | |
| const starRating = y.querySelector('.ipc-rating-star--rating').innerText; | |
| const ranking = heading[0]; | |
| const name = heading[1]; | |
| const year = metadata[0].innerText; | |
| const duration = metadata[1].innerText; | |
| let rating = ''; | |
| if (metadata.length > 2) | |
| rating = metadata[2].innerText; | |
| const runtimeRegex = duration.match(/(?:(\d+)h)?\s?(?:(\d+)m)?/); | |
| const runtime = (parseInt(runtimeRegex[1] || "0", 10) * 60) + parseInt(runtimeRegex[2] || "0", 10); | |
| output += `${ranking},"${name}",${year},${duration},${runtime},${rating},${starRating}\n` | |
| }); | |
| console.log(output); | |
| }()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment