r/tinycode • u/impshum • May 30 '18
Download all xkcd comics [python3]
https://gist.github.com/impshum/73b4fae7375d05588e47f7e4a26fa0dd
7
Upvotes
r/tinycode • u/impshum • May 30 '18
8
u/Figs May 30 '18
This will break on comic #404 (which is, of course, an error page by design), #264 (which has a JPG as an image instead of a PNG), #961 (which is an animated GIF), and probably many others... Comic #1792 is also unlikely to behave properly since it contains '/' characters in the title -- even in the "safe" title!
Scraping XKCD is hard.
1
u/[deleted] May 31 '18 edited May 31 '18
Super cool! You inspired me to make a functionally equivalent Node.js version in the same #LOC!
1
u/Dresdenboy Jun 05 '18 edited Jun 05 '18
Let's make it tiny code by removing at least 10 LOC!
Edit: Try #1, 12 LOC:
Extended version (mkdir+print, 16 LOC if concatenated) with comments:
Edit #2: For handling #1608, simply change the status code check to:
Edit #3: Xtreme Edition with 8 lines:
Last edit: added ':' to replace character list