Created
December 13, 2022 01:42
-
-
Save bergfelipe/486f1d1695e4a048eb6c7b5de87d7ff6 to your computer and use it in GitHub Desktop.
nokogiri
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
| #! /usr/bin/env ruby | |
| require 'nokogiri' | |
| require 'open-uri' | |
| # Fetch and parse HTML document | |
| doc = Nokogiri::HTML(URI.open('https://www.imdb.com/chart/top/?ref_=nv_mv_250')) | |
| table = doc.css('table.chart').css('tbody.lister-list') | |
| open('filmes.csv', 'w') do |arquivo| | |
| table.search('tr').each do |tr| | |
| title = tr.css('td.titleColumn').css('a').text | |
| note = tr.css('td.ratingColumn').css('strong').text | |
| arquivo.puts %("#{title.chomp}";"#{note.chomp}") | |
| next if tr['class'] == 'watchlistColumn' | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment