•2íЕ’¸¸.‚‹º.ŒŒ/„¤/ÿ?€¼=ƒËŠˆ’žYì.w'ŒÂ¡θ',¡нþ
No TIO for the entire program, because the .w
builtin to access the internet doesn't work on TIO.
Explanation:
We start by creating the url, and accessing it:
•2íЕ # Push compressed integer 190437 (the id of this answer)
’¸¸.‚‹º.ŒŒ/„¤/ÿ?€¼=ƒËŠˆ’
# Push dictionary string "api.stackexchange.com/posts/ÿ?site=codegolf",
# where the `ÿ` is automatically filled with the 190437
žY # Push builtin "https://"
ì # And prepend it in front of the string
.w # Go to this website, and get all its contents
Try it online (without the .w
).
After that, we extract the score from the JSON:
'ŒÂ '# Push dictionary string "score"
¡ # Split the website content on this
θ # Only leave the last item (of the two)
',¡ '# Split this string on ","
н # And this time leave the first item (i.e. `":10`)
þ # Only leave the digits of this string
# (which is output implicitly as result)
Try it online.
An equal 10-bytes alternative for this second part could be:
„ŒÂ‚¡ # Push dictionary string "score after"
# # Split it on spaces: ["score","after"]
¡ # Split the website content on these
Ås # Only leave the middle element
þ # Only leave the digits of this string
# (which is output implicitly as result)
Try it online.
See this 05AB1E tip of mine (sections How to use the dictionary? and How to compress large integers?) to understand why •2íЕ
is 190437
, ’¸¸.‚‹º.ŒŒ/„¤/ÿ?€¼=ƒËŠˆ’
is "api.stackexchange.com/posts/ÿ?site=codegolf"
, 'ŒÂ
is "score"
, and „ŒÂ‚¡
is "score after"
.
PS/EDIT: I realize that by using the þ
I assume I will never get a negative score. ;)
perl -e'($_)=`curl -s http://api.stackexchange.com/2.2/posts/123?site=codegolf`;/score":(\d+)/&&print$1'
looks like it should work, but doesn't. But maybe someone can use that. \$\endgroup\$