Last active
September 13, 2023 21:55
-
-
Save jamie/42660a583781a68a6dcf to your computer and use it in GitHub Desktop.
Downloads 1080p wallpapers for Steam cards, using http://www.steamcardexchange.net/index.php?showcase as an index
This file contains hidden or 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
# INSTALLATION | |
# Requres ruby 1.9+, and the nokogiri gem (gem install nokogiri) | |
# Should work fine on Windows, Mac, Linux | |
# Also needs a working curl, so windows users might need to do some work there. | |
# USAGE | |
# Hit up the game you want to scrape from Steam Card Exchange, like so: | |
# http://www.steamcardexchange.net/index.php?gamepage-appid-440 | |
# Then, referencing the app ID in the url, run this script: | |
# ruby download.rb <appid> | |
# It will output the download commands as it's working, and download to the working directory. | |
# Direct any bug reports to http://www.reddit.com/r/Steam/comments/2bglrp/psa_steam_trading_cards_are_1920x1080_wallpapers/cj572kz | |
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
url = "http://www.steamcardexchange.net/index.php?gamepage-appid-#{ARGV[0]}" | |
puts "Loading #{url}" | |
doc = Nokogiri::HTML(open(url)) | |
commands = [] | |
game_name = doc.css(".game-title .empty").first.content | |
doc.css(".showcase-element-card").each do |card| | |
begin | |
number = card.css('.card-number').first.content.split(" ")[1] # Card X of Y | |
url = card.css('.card-image-link').first.attr(:href) | |
name = card.css('.card-name').first.content | |
filename = "#{game_name} (#{number}) #{name}.jpg" | |
commands << %(curl -so "#{filename}" #{url}) | |
rescue | |
end | |
end | |
doc.css(".showcase-element-background").each do |card| | |
begin | |
url = card.css('.background-hd-link').first.attr(:href) | |
name = card.css('.background-name').first.content | |
filename = "#{game_name} - #{name}.jpg" | |
commands << %(curl -so "#{filename}" #{url}) | |
rescue | |
end | |
end | |
commands.uniq.each {|cmd| puts cmd; system cmd} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment