•2íЕ’¸¸.‚‹º.ŒŒ/„¤/ÿ?€¼=ƒËŠˆ’žYì.w'ŒÂ¡θ',¡нþ
整个程序没有TIO,因为 .w
访问Internet内置功能在TIO上不起作用。
说明:
我们首先创建URL,然后访问它:
•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
在线尝试(不使用.w
)。
之后,我们从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)
在线尝试。
第二部分的等效10 字节替代方法可能是:
„ŒÂ‚¡ # 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)
在线尝试。
请参阅我的05AB1E技巧(如何使用字典?和如何压缩大整数部分)以了解为什么•2íЕ
is 190437
,’¸¸.‚‹º.ŒŒ/„¤/ÿ?€¼=ƒËŠˆ’
is "api.stackexchange.com/posts/ÿ?site=codegolf"
,'ŒÂ
is "score"
和„ŒÂ‚¡
is "score after"
。
PS / EDIT:我意识到使用þ
I会永远不会得到负分数。;)
perl -e'($_)=`curl -s http://api.stackexchange.com/2.2/posts/123?site=codegolf`;/score":(\d+)/&&print$1'
看起来应该可以,但不能。但是也许有人可以使用它。