Created
May 29, 2017 18:56
-
-
Save cia-rana/54542259253667fd22115f9f41e36f86 to your computer and use it in GitHub Desktop.
To Get Pokémon Global Link Season Ranking
This file contains 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
require "net/http" | |
require "uri" | |
require "json" | |
require "pp" | |
def post_pgl_ranking(season_id, battle_type, page_number) | |
url = "https://3ds.pokemon-gl.com/frontendApi/gbu/getSeasonRanking" | |
uri = URI.parse(url) | |
timestamp = Time.now.to_i | |
request = Net::HTTP::Post.new(uri.request_uri) | |
request["referer"] = "http://3ds.pokemon-gl.com/battle/" | |
request.set_form_data({ | |
'languageId' => '1', | |
'seasonId' => season_id, | |
'page' => page_number, | |
'battleType' => battle_type, | |
'timezone' => 'JST', | |
'timeStamp' => timestamp | |
}, '&') | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = (uri.scheme == "https") | |
response = http.request(request) | |
JSON.parse(response.entity).to_h | |
end | |
pp post_pgl_ranking(201, 1, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment