Skip to content

Instantly share code, notes, and snippets.

@barockok
Last active June 10, 2016 16:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barockok/6513153 to your computer and use it in GitHub Desktop.
Save barockok/6513153 to your computer and use it in GitHub Desktop.
Al-quran 30 Juz 114 surah downloader reciter : Saad Al Ghamidi
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
@ridwanashiraf
Copy link

please i want kira'a full quran

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment