Skip to content

Instantly share code, notes, and snippets.

@skojin
Last active April 10, 2017 07:58
Show Gist options
  • Save skojin/ae676c7bc7290086c7e6f727d7a98ddd to your computer and use it in GitHub Desktop.
Save skojin/ae676c7bc7290086c7e6f727d7a98ddd to your computer and use it in GitHub Desktop.
backup imhonet.com
COOKIE = ARGV[0]
TO = ARGV[1] || 'json/bookmarks'
`mkdir -p #{TO}`
%w{films serials books games person}.each do |type|
print "#{type} "
(1..99).each do |page|
json = `curl 'http://#{type}.imhonet.ru/web.php?path=favorites/all/&domain=#{type}&page=#{page}' --silent -H '#{COOKIE}' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36' -H 'Accept: application/json' -H 'Referer: http://films.imhonet.ru/favorites/all/' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' --compressed`
break unless json[0] == '{' # if content is not json, then pager ended
print '.'
File.write("#{TO}/#{type}_%02d.json" % page, json)
end
puts
end
USER = ARGV[0] # username
TO = ARGV[1] || 'json/rates'
`mkdir -p #{TO}`
%w{films serials books games person}.each do |type|
print "#{type} "
(1..99).each do |page|
json = `curl 'http://user.imhonet.ru/web.php?path=content/#{type}/rates/&user_domain=#{USER}&domain=user&page=#{page}' --silent -H 'x-requested-with: XMLHttpRequest' -H 'accept: application/json'`
break unless json[0] == '{' # if content is not json, then pager ended
print '.'
File.write("#{TO}/#{type}_%02d.json" % page, json)
end
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment