Last active
June 10, 2016 16:02
-
-
Save barockok/6513153 to your computer and use it in GitHub Desktop.
Al-quran 30 Juz 114 surah downloader
reciter : Saad Al Ghamidi
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 'mechanize' | |
require 'nokogiri' | |
require 'active_support/all' | |
class SaadAlGhamidi | |
def initialize | |
@page_agent = Mechanize.new | |
@file_agent = Mechanize.new | |
@file_agent.pluggable_parser.default = Mechanize::Download | |
end | |
def lists | |
_index_page = @page_agent.get 'http://www.mp3quran.net/eng/s_gmd_english.html' | |
html = Nokogiri::HTML(_index_page.body) | |
@_list = [] | |
_table = html.css('table')[1] | |
114.times do |i| | |
index = i + 2 | |
tr_target = _table.at("tr:nth-child(#{index})") | |
@_list << {:file_name => "#{'%03d' % (index-1)} - #{tr_target.at('td:nth-child(2)').text.strip}.mp3", :url => tr_target.at('td:last-child a').attr('href') } | |
end | |
@_list | |
end | |
def download_all | |
lists.each do |list| | |
puts "-------> Downloading #{list[:file_name]}" | |
@file_agent.get(list[:url]).save("#{list[:file_name]}") | |
puts "<------- #{list[:file_name]} saved" | |
end | |
end | |
end | |
SaadAlGhamidi.new.download_all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
please i want kira'a full quran