0

I want to download the content from the following link to a file .

I tried using wget and curl commands , the file has downloaded data but is not in readable format or json string.

command I have used is :

    wget -O ~/ks/json.txt "http://api.geonames.org/postalCodeLookupJSON?postalcode=6600&country=AT&username=demo"

I want the output file to contain data in json format itself as shown in the link.

EDIT

I used Vi editor to read the output , below is the sample i got as output :

^_<8b>^H^@^@^@^@^@^D^@Õ[^?wÚ8³þ*ºì<9e>¾d^Wÿ¶1Ð$û¦MÚdÛ$½MÚݾKO<8e>°^E(16kË¡´§÷³ß^YÉ^F^C&%ÙûÏÍÙ-F<9e>^Y<8d>¤<99>G3#ñ­Á^E<9b>d<8d>Þ_ß^Z<82><8e>ð¡1¦a<92>L^[­Æ<84>NS^Væ^A<83>ç9MãÆçV#<99>Å,mô¾5R6Í^E^U<<89>^[=Ûi5ò<8c>¥7<lô^\ÏqÝvÙ"æSÖè^Aõ<88>g<82><81>8<90>E<83><80>MÅMJ^E¼ò;­Æ4M<86><b7|BGH=^Vb<9a>õ^Lc6<9b>é£<94>ÞSAS=H&<86>z4Âд¼6^[ºf7^XZagà<87>~׶CÚa<8e>^[Ø<83>ß²^CËî<^K^OxÈbÁ<83>$~<96>^^¼{ýlx`A÷!Ϧ^Q<9d>ßÄt<82><9d>½&oR<9e><8d>cJ®èdJÅ^XH"^^ß^Uz<80>^Z<99> Á]rÏÒa<94>̤^^8´Ì(Fj<8c>´;%AË
K S Nidhin
  • 2,414
  • 2
  • 17
  • 39
  • It is working for me. I am using vi editor. Which editor u used to open the file. – manish Jan 13 '15 at 08:00
  • I used VI itself but still , the output im getting I have added in question. – K S Nidhin Jan 14 '15 at 07:04
  • I think encoding settings of your vi editor is not correct. Check this may be helpful http://stackoverflow.com/questions/1174847/how-to-set-the-character-encoding-for-a-file-in-vim – manish Jan 14 '15 at 09:45

2 Answers2

2
$ curl -X GET "http://api.geonames.org/postalCodeLookupJSON?postalcode=6600&country=AT&username=demo" > out.json
Alexander
  • 10,939
  • 5
  • 52
  • 71
0

Using curl the payload is saved and readable by a JSON parser (node in my case)

curl "http://api.geonames.org/postalCodeLookupJSON?postalcode=6600&country=AT&username=demo" > file.json
Jamie W
  • 71
  • 4