Skip to content

Instantly share code, notes, and snippets.

Created February 28, 2017 02:46
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Downloader script for
#!/usr/bin/env ruby
# This script only support ASCII format
# and tick download.
require 'uri'
require 'net/http'
require 'mechanize'
agent =
agent.pluggable_parser.default = Mechanize::Download
for i_date in 2009..2017 # change date
date = i_date.to_s
for i_month in 1..12 # change month
month = '%02d' % i_month
datemonth = date + month
fxpair = 'XAUUSD' # change your instrument
platform = 'ASCII'
timeframe = 'T'
saved_name = 'HISTDATA_COM_' + [platform, fxpair, timeframe, datemonth].join('_') + '.zip'
referer_uri = "{platform.downcase}/tick-data-quotes/#{fxpair.downcase}/#{date}/#{month}"
puts "Downloading: #{saved_name}"
if File.exist?saved_name
puts "Downloaded: #{saved_name}, skipping."
p = agent.get(referer_uri)
next_p = p.form_with(:name => 'file_down').submit
Copy link

Thanks, it's saving me a lot of time!

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