Public
Scrapes a cat adoption site and returns cats as JSON
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data ā all from the browser, and deployed in milliseconds.
Scrapes the PAWS adoptable cats page and republishes the listing as an RSS 2.0 feed ā one item per cat, with a plain-text summary and a rich HTML card (photo + details + link back to PAWS).
| Path | Behavior |
|---|---|
/feed.xml | The RSS feed (Content-Type: application/rss+xml). |
/ | 302 redirect to /feed.xml (preserves query string). |
| anything else | 404 Not found. |
| Param | Effect |
|---|---|
?sex=⦠| Filter to male / female (also accepts m / f). Invalid values return 400. |
?kitten=1 | Kittens only ā drop any cat whose age mentions year. Cats with no listed age (typically adoption-pending) are kept. Also accepts true / yes / on. |
?fresh=1 | Bypass the 5-minute server cache and re-scrape immediately. |
?url=⦠| Scrape a different listing URL (always uncached). |
Each <item> includes:
<title>āName ā Sex, Age(with(adoption pending)suffix when applicable). Example:Bahama ā Female, 5 years 2 months.<link>ā the cat's PAWS detail page (or the listing URL when none exists).<guid>ā the detail URL (permalink) when available, otherwise a stablepaws-cat:<name>token.<enclosure>ā the cat's photo URL.<description>ā a plain-text one-liner for list previews. Example: "Bahama is a 5 years 2 months old female Domestic Shorthair cat available for adoption at PAWS - Lynnwood."<content:encoded>ā a self-contained HTML card with photo, a labeled details table, and a "View on PAWS ā" link. Styles are inlined so most readers render it correctly.
Adoption-pending cats show a name and photo but PAWS hides their details, so the other fields come back
nulland the title is suffixed with(adoption pending).
The feed asks readers to poll as often as they're willing to:
- HTTP:
Cache-Control: no-store, no-cache, must-revalidate, max-age=0(plusPragma/Expiresfor older clients). - RSS:
<ttl>1</ttl>and thesy:syndication module'supdatePeriod=hourly/updateFrequency=1. lastBuildDateandpubDateare regenerated on every response so the feed always looks new.
A 5-minute server-side cache of the parsed cat list keeps us from hammering
paws.org on every poll; it can be bypassed with ?fresh=1.
Rendering mermaid diagram...
main.tsā HTTP routing, caching, query params, RSS XML generation.scraper.tsāfetch+cheerioparsing of the PAWS markup intoCatobjects.test.tsā runs the scraper against the live site and prints a summary.
- PAWS serves server-rendered HTML, so a plain
fetch+cheerioworks well ā no headless browser needed. - The parser keys off PAWS's
card-block__*CSS classes. If PAWS redesigns their site, update the selectors inscraper.ts. - Photos are hosted on Petango (PAWS's adoption management system); promo
cards are filtered out by requiring the image URL to be on
petango.com.