A small CLI for scraping apartment listing leads from Apartments.com category pages.
It fetches the page HTML, reads the first script[type="application/ld+json"] block, parses the apartment listing data, and writes both JSON and CSV outputs.
go run ./cmd/aptscom "https://www.apartments.com/off-campus-housing/ca/santa-clara/santa-clara-university/"go build -o aptscom ./cmd/aptscom
./aptscom "https://www.apartments.com/off-campus-housing/ca/san-jose/san-jose-state-university/"go install github.com/builderorin/aptscom/cmd/aptscom@latestThen run:
aptscom "https://www.apartments.com/off-campus-housing/ca/santa-clara/santa-clara-university/"The CLI writes output relative to your current working directory, not the binary location.
For example, if you run this from ~/Desktop/test:
cd ~/Desktop/test
aptscom "https://www.apartments.com/off-campus-housing/ca/santa-clara/santa-clara-university/"it will create:
scraped/json/santa-clara-university.json
scraped/csv/santa-clara-university.csvThe parser currently pulls these fields into CSV:
nameurltelephonepricelow_pricehigh_pricestreet_addressaddress_localityaddress_regionpostal_codeaddress_countrylatitudelongitudeamenity_features
- Uses the first
application/ld+jsonscript tag on the page. offerssupports bothOfferandAggregateOffershapes.amenity_featuresis currently a flattened string column in the CSV.