Finding books in nearby library branches by Alex Chan

Published on 21 May 2026 at 16:20

Thank you to Alex Chan for allowing me to repost this article which discusses a tool Chan built to help her find the nearest library carrying the book she'd next like to read. You can find this article in its original form on the author's website. It was originally posted on October 10, 2022.


Finding books in nearby library branches

by Alex Chan

I’m trying to make better use of my local public library. I want to read more books, and borrowing from the library keeps the habit sustainable. It also saves a fair bit of money, and I don’t have to decide what to do with books when I’m done.

Recently, I built a tool to help me find books to borrow, and it’s working pretty well.

It starts with my library’s online catalogue. When I find a book I might be interested in reading, I tap the bookmark icon in the upper right-hand corner of the search result.

This saves the book to a list on the library site, which I can view on my account page. But the website makes it hard to work out what I can actually borrow. The example above says “92 copies”, which means 92 physical books floating around the library network – but they could be on loan, on hold for another reader, or in a branch halfway across the county.

Image Description: Two stacks of books create a hallway of reading material viewed through a fisheye lens with a bright window at the center.

Credit: Aibek Skakov / Pexels

If I tap “View availability”, I get a long list of every copy in the network, its location and status.

Given there are dozens of books I’m interested in, scrolling lists like this gets tedious. There must be a better way!

I’ve written a Python script that scrapes the library website, fetches all this information, then presents it in a nicer way. The library website uses a platform called Spydus, and I found some existing code for logging into Spydus sites by pretending to be a browser. Then I use BeautifulSoup to parse the data from the library HTML, and Jinja to render it in a nicer way.

It shows the list of books I’m interested in and highlights the copies which are actually available – and specifically, copies that are available in branches within walking distance of my home. I could walk in and borrow any of these books immediately.

Over time, I expect books to gradually move around as they’re borrowed by other readers – so even if a book isn’t in a nearby branch today, it might be sometime in the future. I can order books from a different branch to pick up locally, but right now I have plenty to choose from.

This filtered list is particularly useful when I’m in a hurry. There’s a library branch near the train station, so I can pop in and pick up a few books on the way to the office – but I can’t take too long, or I’ll be late for work. Having a list of what’s readily available means I can be in and out quickly.

The tool includes a pick list of branches. For example, if I’m visiting Ware to get my pictures framed, I can find out if there’s anything I want to borrow at the library branch just down the road.

This is some JavaScript that listens to the onchange event on the checkboxes; it re-sorts the list whenever I check or uncheck a branch.

I’ve already used this for several rounds of borrowing, and it’s working great. Having a steady supply of new and interesting books is encouraging me to read more, and I feel less guilt about abandoning a book I’m not enjoying – I’m not losing anything. (I can only read one book at a time, so a bad book really stops me in my tracks.)

Although I don’t expect anybody else to use this tool directly, I’ve put the code on GitHub. There may be ideas or techniques here that apply to a different problem you have – and while you read through that, I have a stack of library books to finish.


From Alex Chan

I’m a software developer, writer, and a hand crafter, and I live in the UK. In my day job I build software for digital preservation, and I think a lot about archiving and long-term systems.

This website is where I share stuff I find interesting or fun. That includes notes on technical problems I’ve solved, personal reflections or thoughts, and fun toys that I’ve built.

I’m queer and trans, and my pronouns are “they” or “she”.

I hope you like it!

Add comment

Comments

There are no comments yet.