Created
July 1, 2017 16:37
-
-
Save LulzAugusto/eefb39812d7dc4994dfd154a0b2c0840 to your computer and use it in GitHub Desktop.
Scraps movie titles and ratings from your filmow profile and exports them to a .csv file. https://filmow.com/usuario/<your_username>/ja-vi/
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
const movies = [] | |
$('#movies-list li').each(function () { | |
console.log('scrapping this:', this) | |
const $ratingEl = $(this).find('.star-rating') | |
const rating = $ratingEl.length > 0 ? $ratingEl.data('originalTitle').split(' ')[1] : '' | |
const title = $(this).find('a.cover img').attr('alt').split('(')[1].split(')')[0] | |
movies.push([title, rating]) | |
}) | |
console.log(movies) | |
let csvContent = 'data:text/csv;charset=utf-8,' | |
movies.forEach((movie, index) => { | |
const dataString = movie.join(',') | |
csvContent += index < movies.length ? `${dataString}\n` : dataString | |
}) | |
const encodedUri = encodeURI(csvContent) | |
window.open(encodedUri) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment