Skip to content

Instantly share code, notes, and snippets.

@DataKinds
Last active April 9, 2019 03:27
Show Gist options
  • Save DataKinds/8365053c42cedb812a2fbb998535d9a7 to your computer and use it in GitHub Desktop.
Save DataKinds/8365053c42cedb812a2fbb998535d9a7 to your computer and use it in GitHub Desktop.
download all top fonts off dafont
require "nokogiri"
require "open-uri"
`rm fontUrls`
fontUrlFile = File.open("fontUrls", "a")
(1..50).each do |pageIndex|
page = Nokogiri::HTML(open("http://www.dafont.com/top.php?page=#{pageIndex}"))
page.css(".dlbox .dl").each do |downloadButton|
fontUrlFile.puts "https:#{downloadButton['href']}"
puts downloadButton["href"]
end
end
fontUrlFile.close
File.read("fontUrls").each_line do |url|
puts url
Thread.fork do
`curl '#{url.chomp}' -o '#{url.scan(/f=(.+)$/)[0][0]}.zip'`
end
end
require "fileutils"
`mkdir ohLordTheFonts`
Dir.glob("*.zip").each do |fileName|
`unzip -n #{fileName} -d ohLordTheFonts/`
end
`#{DATA.read}`
__END__
cd ohLordTheFonts && find . -not -name "*.otf" -not -name "*.ttf" -delete;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment