Skip to content

Instantly share code, notes, and snippets.

@teesid
Created April 17, 2019 11:45
Show Gist options
  • Save teesid/414bf419d99ab63ec19691a2238c1f62 to your computer and use it in GitHub Desktop.
Save teesid/414bf419d99ab63ec19691a2238c1f62 to your computer and use it in GitHub Desktop.
A simple script to pull Dtac Go Inter's roaming parters from their website in to CSV. This works as of 2019-04-17
#!/bin/bash
echo "Zone,Country,Network,Code,399?,899?"
# Take note of the -Mj + -Mr jq trick. Extremely useful!
curl -G -s 'http://dtac.co.th/gointer-2019/rates.php?lang=EN' \
| jq -Mr '.country
| (.Asia | map(["Asia", .]))
+ (.Oceania | map(["Oceania", .]))
+ (.America | map(["America", .]))
+ (.Europe | map(["Europe", .]))
+ (.Africa | map(["Africa", .]))
| map("curl -G -s \"http://dtac.co.th/gointer-2019/rates.php?lang=EN\" --data-urlencode c=\"\(.[1])\" \\
| jq -Mj \".val | [ \\\"\(.[0])\\\", .Name, .Network, .Code ]
| @csv\";
echo -n ,
curl -G -s \"http://dtac.co.th/gointer-2019/package.php?lang=EN\" --data-urlencode c=\"\(.[1])\" \\
| jq -Mr \".val | [.S399, .S899]
| @csv\"
")
| .[]' \
| /bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment