The Python one has already won, but regardless...
bash + curl + sed; 8888 ~91 heh bytes
printf "$(curl -s https://xkcd.com/$12048/info.0.json|sed 's/.*alt"*"alt": "\([^"]\+\)"//;s/", "img":.*/\1/')\n"
Yay for regex JSON parsing!
EDIT NoLongerBreathedIn noticed (648 days into the future!) that this failed on post 2048 because of an unexpected \"
in that entry's JSON. The regex has been updated above; it used to be sed 's/.*alt": "\([^"]\+\).*/\1/')
.
The printf
wrapper neatly handles the fact that Unicode characters are represented in \unnnn
notation:
$ printf "$(curl -s https://xkcd.com/1538/info.0.json | sed 's/.*alt"*"alt": "\([^"]\+\)"//;s/", "img":.*/\1/')\n"
To me, trying to understand song lyrics feels like when I see text in a dream but it𝔰 hอᵣd t₀ ᵣeₐd aกd 𝒾 canٖt fཱྀcu༧༦࿐༄
This fails with posts 404 and 859:
404
$ printf "$(curl -s https://xkcd.com/404/info.0.json | sed 's/.*alt": "\([^"]\+\).*/\1/')\n"
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
859
$ printf "$(curl -s https://xkcd.com/859/info.0.json | sed 's/.*alt": "\([^"]\+\).*/\1/')\n"
Brains aside, I wonder how many poorly-written xkcd.com-parsing scripts will break on this title (or ;;\n$
The $
at the end of the output is my prompt, and the literally-printed \n
immediately before it is part of the printf string.
I deliberately used printf
because it would parse Unicode and fall over terribly on this specific post.