Skip to main content
added 301 characters in body
Source Link
i336_
  • 151
  • 5

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.

The Python one has already won, but regardless...

bash + curl + sed; 88 bytes

printf "$(curl -s https://xkcd.com/$1/info.0.json|sed 's/.*alt": "\([^"]\+\).*/\1/')\n"

Yay for regex JSON parsing!

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": "\([^"]\+\).*/\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.

The Python one has already won, but regardless...

bash + curl + sed; 88 ~91 heh bytes

printf "$(curl -s https://xkcd.com/2048/info.0.json|sed 's/.*"alt": "//;s/", "img":.*//')\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": "//;s/", "img":.*//')\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.

Source Link
i336_
  • 151
  • 5

The Python one has already won, but regardless...

bash + curl + sed; 88 bytes

printf "$(curl -s https://xkcd.com/$1/info.0.json|sed 's/.*alt": "\([^"]\+\).*/\1/')\n"

Yay for regex JSON parsing!

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": "\([^"]\+\).*/\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.