https://github.com/encodeous/random-xkcd
A project that brings you a random xkcd post every time!
https://github.com/encodeous/random-xkcd
azure dotnet fun html xkcd
Last synced: 10 months ago
JSON representation
A project that brings you a random xkcd post every time!
- Host: GitHub
- URL: https://github.com/encodeous/random-xkcd
- Owner: encodeous
- License: mit
- Created: 2020-11-08T23:08:01.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-04-15T20:25:47.000Z (almost 2 years ago)
- Last Synced: 2025-02-09T20:27:47.625Z (12 months ago)
- Topics: azure, dotnet, fun, html, xkcd
- Language: C#
- Homepage:
- Size: 17.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## `random_xkcd::A_random_project`
> xkcd is a webcomic of romance, sarcasm, math, and language.
This project grabs a completely random comic at the click of a button.
## `A random comic for you! (Updated every few minutes)`

And a dark mode one too!

## `tl;dr`
For markdown, add `` to your profile page for a random comic every time you reload! (Or once every few minutes due to caching, like GitHub)
For html, add `
` to the page.
The same applies for the dark mode, where the API link is `https://ec-xkcd.azurewebsites.net/api/xkcddark`
*Please note: If this api does not work, it probably means I have ran out of azure credits!*
## `API`
Send a http request to [https://ec-xkcd.azurewebsites.net/api/xkcd](https://ec-xkcd.azurewebsites.net/api/xkcd "https://ec-xkcd.azurewebsites.net/api/xkcd") and it will respond with a random xkcd as a png.
A dark mode version is also available where a greyscale and color invert filter has been applied to the image.
[https://ec-xkcd.azurewebsites.net/api/xkcddark](https://ec-xkcd.azurewebsites.net/api/xkcddark "https://ec-xkcd.azurewebsites.net/api/xkcddark")
## `How it works`
1. On every HTTP request, the program reads the RSS feed of xkcd to obtain the latest post.
2. Then, a random post, r is selected in the range `[1, x]` where x is the latest post.
3. A HTTP request to `https://xkcd.com/` is made, and the HTML is parsed.
4. The image is extracted and then loaded into memory.
5. The API then returns the extracted image.