Created
January 18, 2017 03:19
-
-
Save ggtmtmgg/ef005419b123a84ebc540947dadedf43 to your computer and use it in GitHub Desktop.
This file contains 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
require 'nokogiri' | |
require 'open-uri' | |
URL = 'https://www.youtube.com' | |
PLAYLIST_URL = URL + '<Playlist Path>' | |
puts = 'Scraping..' | |
doc = Nokogiri::HTML(open(PLAYLIST_URL)) | |
videos_xpath = '//*[@id="pl-load-more-destination"]/tr' | |
videos = doc.xpath(videos_xpath) | |
a_tag_xpath = 'td[4]/a' | |
videos.each do |video, i| | |
a_tag_xpath = 'td[4]/a' | |
a_tag = video.xpath(a_tag_xpath) | |
path = a_tag.attr('href').value.gsub(/\&.*/, '') | |
puts full_url = URL + path | |
`youtube-dl --extract-audio --audio-format mp3 '#{full_url}'` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment