Well, actually, this is a Python library for accessing xkcd.

It does contain five scripts- one of which does download all xkcds onto your computer. (I haven't actually downloaded all ~800 yet though). There are two others, for opening up random/last xkcds in your web browser, and two others for downloading the random/latest xkcd to your computer.

Plus, you can use the functions available in the library for doing other things.

You need Python 2.x (2.7 is the latest version) to install: you can get it here.

As of version 1.1, you no longer need the feedparser module. I've modified it to use xkcd's JSON interface, which is good for two reasons: the RSS feed sometimes has things in it that aren't comic) which break the old implemention, and secondly: it removes the only third-party dependency.

Download from here. The zip includes seven files (minus the readme, which has all this text):

-dowallxkcd.py: script to download all xkcds
-dowlastxkcd.py: script to download latest xkcd
-dowrandxkcd.py: script to download random xkcd
-lastxkcd.py: script to open a random xkcd in browser
-randxkcd.py: script to open the latest xkcd in browser
-xkcd.py: the library itself
-xkcd-1.0.zip: a zipped Python package - if you know how to install Python packages just install this

To install manually on Windows, you'd put xkcd.py in C:\Python27\lib\site-packages (wherever Python is installed, then \lib\site-packages). The scripts can go anywhere.

To install manually on Linux... it goes to the same lib/site-packages folder, but I'm not sure where this is- either /lib/python/ or /usr/lib/python, probably.
Nice job, you clearly put a lot of thought into this. My main concern is legality; I presume this is for private consumption of XKCD, but I wonder why then one couldn't just read them online. Smile
I believe this was in response to our chat yesterday about how I'd like to have my Android phone be able to download all the xkcds when it reaches a hotspot and then allow me to view them offline (the rest of the time). Thank you tc01 Smile
_player1537 wrote:
I believe this was in response to our chat yesterday about how I'd like to have my Android phone be able to download all the xkcds when it reaches a hotspot and then allow me to view them offline (the rest of the time). Thank you tc01 Smile
Ahh, that makes sense. Actually, I think it would be more useful to be expanded to be able to download any given content from a website or webpage for later viewing. Smile
Indeed, that's why I made the "download all xkcds" thing.

I already had the code for viewing them in the web browser and retrieving the numbers and URLs and things. Then _player suggested downloads, I wrote some code to get the direct picture links and... got a bit carried away, maybe. Razz

I didn't realize how easy it is to download a page in Python- just use urllib to read it and copy all the data to a file. Pretty easy to expand.

I have a similar thing for bash.org in progress (though it just prints the quote text to the terminal), again based on the work I did for my IRC bot.
1337 hax0r ju r
wow, this is pretty good Very Happy

Now if only there was one for notalwaysright.com XD (wait, bad idea, that could take forever)
TC01 wrote:
Indeed, that's why I made the "download all xkcds" thing.

I already had the code for viewing them in the web browser and retrieving the numbers and URLs and things. Then _player suggested downloads, I wrote some code to get the direct picture links and... got a bit carried away, maybe. Razz

I didn't realize how easy it is to download a page in Python- just use urllib to read it and copy all the data to a file. Pretty easy to expand.

I have a similar thing for bash.org in progress (though it just prints the quote text to the terminal), again based on the work I did for my IRC bot.
Sounds cool! If you added the ability to identify and spider links on each page, you'd have a great program to grab pages when you touch a hotspot for reading on the bus/train/transportation of your choice.
KermMartian wrote:
TC01 wrote:
Indeed, that's why I made the "download all xkcds" thing.

I already had the code for viewing them in the web browser and retrieving the numbers and URLs and things. Then _player suggested downloads, I wrote some code to get the direct picture links and... got a bit carried away, maybe. Razz

I didn't realize how easy it is to download a page in Python- just use urllib to read it and copy all the data to a file. Pretty easy to expand.

I have a similar thing for bash.org in progress (though it just prints the quote text to the terminal), again based on the work I did for my IRC bot.
Sounds cool! If you added the ability to identify and spider links on each page, you'd have a great program to grab pages when you touch a hotspot for reading on the bus/train/transportation of your choice.
You mean something like wget oh wait. Razz
TheStorm wrote:
KermMartian wrote:
Sounds cool! If you added the ability to identify and spider links on each page, you'd have a great program to grab pages when you touch a hotspot for reading on the bus/train/transportation of your choice.
You mean something like wget oh wait. Razz
Well yeah, but if we discouraged everyone from making things that had already been made, I feel like we'd miss out on a lot of beginner projects that eventually lead users to make more unique, innovative, and/or original works Smile
KermMartian wrote:
TheStorm wrote:
KermMartian wrote:
Sounds cool! If you added the ability to identify and spider links on each page, you'd have a great program to grab pages when you touch a hotspot for reading on the bus/train/transportation of your choice.
You mean something like wget oh wait. Razz
Well yeah, but if we discouraged everyone from making things that had already been made, I feel like we'd miss out on a lot of beginner projects that eventually lead users to make more unique, innovative, and/or original works Smile
Oh I agree, and wget's overkill for 90% of what people need anyway.
TheStorm wrote:
KermMartian wrote:
TheStorm wrote:
KermMartian wrote:
Sounds cool! If you added the ability to identify and spider links on each page, you'd have a great program to grab pages when you touch a hotspot for reading on the bus/train/transportation of your choice.
You mean something like wget oh wait. Razz
Well yeah, but if we discouraged everyone from making things that had already been made, I feel like we'd miss out on a lot of beginner projects that eventually lead users to make more unique, innovative, and/or original works Smile
Oh I agree, and wget's overkill for 90% of what people need anyway.
Funny you should mention that; every time I want to do something new in which I mash wget into a complex perl or bash script that does other things, I soon discover that wget already does everything I want to add on its own. Smile
I've released a 1.1 update to this library (and replaced the attachment in the first post).

The only change this makes: it now uses xkcd's built-in JSON interface rather than the RSS feed to get the latest comic number. This is good for two reasons:

1. It removes the third-party dependency (you now only need Python 2.x)
2. It stops the script from breaking when the RSS contains things other than comics in it (as it occasionally does).
Very nice, glad that you updated it and made it more robust, and moreover, that that hopefully helped your programming skillset in general. Smile
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement