1 | #!/usr/bin/env crystal
|
2 | require "http/client" |
3 | require "json" |
4 | require "uri" |
5 | |
6 | params = URI.escape("How do I know this is real magic?") |
7 | response = HTTP::Client.get("https://8ball.delegator.com/magic/JSON/" + params) |
8 | puts JSON.parse(response.body) |
1 | #!/usr/bin/env ruby
|
2 | require 'json' |
3 | require 'net/http' |
4 | |
5 | params = URI.encode_www_form_component('Can I ask you a question?') |
6 | uri = URI.join('https://8ball.delegator.com/magic/JSON/', params) |
7 | response = Net::HTTP.get(uri) |
8 | puts JSON.parse(response) |
1 | /* global fetch */
|
2 | |
3 | let params = encodeURIComponent("Is today going to be a good day?"); |
4 | let uri = "https://8ball.delegator.com/magic/JSON/" + params; |
5 | fetch(uri) |
6 | .then(response => response.json()) |
7 | .then(json => { |
8 | console.log(json); |
9 | });
|
1 | #!/usr/bin/env python3
|
2 | import http.client |
3 | import json |
4 | import urllib.parse |
5 | |
6 | conn = http.client.HTTPSConnection("8ball.delegator.com") |
7 | question = urllib.parse.quote('Will a black cat cross me today?') |
8 | conn.request('GET', '/magic/JSON/' + question) |
9 | response = conn.getresponse() |
10 | print(json.loads(response.read())) |
Question | Answer | Type |
Do I have toothpaste on my sweater? | Signs point to yes | Affirmative |
Like what you see? | Don't count on it | Contrary |
Will the world end this weekend? | Reply hazy, try again later | Neutral |
Are you feeling lucky? | You may rely on it | Affirmative |
Should I ask for a raise? | Outlook not so good | Contrary |
Did the cat drag it in? | Very doubtful | Contrary |
Will there be more snow? | It is certain | Affirmative |
Should I try to skateboard? | Concentrate and ask again | Neutral |
Is it safe to talk in the meeting? | Without a doubt | Affirmative |
Will OP Deliver? | Don't count on it | Contrary |