Last active
October 27, 2015 14:08
-
-
Save Marahin/436861c3708ed439e4a1 to your computer and use it in GitHub Desktop.
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
Hello, | |
I'm trying to download some API results from | |
http://steamcommunity.com/market/pricehistory/?country=US¤cy=3&appid=730&market_hash_name=Operation%20Phoenix%20Weapon%20Case | |
the link opened in browser works just fine, however when I tried to open it with open-uri (open(link).read()) it threw a [] 400. | |
I was adviced to take a look into headers I send, and so I have found some in Chrome devtools. I now get a response, however it's unreadable, and I suspect it might be due to the encoding / gzip inflation? Not sure, I'm really a rookie. | |
Help will be greatly appreciated. The code I'm using is shown below. :) |
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 'right_http_connection' | |
uri = URI("http://steamcommunity.com/market/pricehistory/?country=US¤cy=3&appid=730&market_hash_name=Operation%20Phoenix%20Weapon%20Case") | |
headers = { | |
'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', | |
'DNT' => '1', | |
'Accept-Encoding' => 'gzip, deflate, sdch', | |
'Accept-Language' => 'pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4,da;q=0.2,de;q=0.2,fr;q=0.2' | |
} | |
http = Net::HTTP.new(uri.host, uri.port) | |
res = http.get(uri.request_uri, headers) | |
p res.body |
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
❯ ruby get.rb [15:00:44] | |
"\x1F\x8B\b\x00\x00\x00\x00\x00\x00\x03\x8A\x8E\x05\x00\x00\x00\xFF\xFF\x03\x00)\xBBL\r\x02\x00\x00\x00" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment