Finding farmland in judicial auctions

First working version
1.5 h

Goal

An agent that works through the Spanish state auction portal auction by auction and lot by lot, reads the description of every asset to keep only the rural plots and leaves in a spreadsheet where each one is, what is being asked, what it was valued at and the link to its notice.

How it works

First the user says what they are after: rural land, and only auctions that are open. With that the agent filters the state auction portal and goes into each auction record to note the amounts, the dates and whether it has lots. Going in is necessary because the results list carries neither the appraisal nor the deposit: those only exist inside.

Then it opens the assets tab and works lot by lot. One auction can mix a flat, a commercial unit and two plots, and the only thing telling them apart is the description the court typed by hand, in free text. From that text comes whether the asset is farmland, how many hectares it has and whether it is irrigated or dry, and everything pulled from it is flagged unverified and kept in columns of its own, apart from what the portal states as data.

To finish, it tips everything into a filterable sheet, one row per plot, so it can be sorted by price or by province without going back into the portal. It runs on demand, not on a schedule. The last pass turned up 26 rural plots in 13 provinces, out of almost a hundred open auctions.

Agent steps
Deliverable
  • A spreadsheet with 27 columns and one row per plot.
  • Per plot: province, municipality, address, land-registry reference, appraisal, auction value, deposit, minimum bid and dates.
  • A direct link to the gazette notice and the court’s literal description of the property.
  • Five agronomic enrichment columns, greyed out and empty: they get filled once the cadastre and the parcel data are crossed in.
Stack
  • Claude Code
  • Spanish state auction portal
  • Python + requests
  • BeautifulSoup
  • openpyxl

Why it matters

Public records are right there and cannot be downloaded. An assistant works out an undocumented portal and understands the free text inside it, which is where the court typed by hand whether the asset is farmland, how big it is and whether it has water, with no format and no two notices alike. With that, a hundred loose notices end up as a table you sort and filter.

What could come next

  1. 01Cross the land-registry reference with the cadastre to pull the real surface area and work out the price per hectare. Today the surface comes from the description the court typed and is flagged unverified, so the one column that would actually sort the spreadsheet cannot be calculated yet.
  2. 02Download the municipality’s agricultural parcel data to get land use, irrigated or dry, and average slope. That is the difference between land you can farm and a hillside of scrub, and right now that distinction has to be looked up by hand, plot by plot.
  3. 03Schedule the sweep every three days and report only the plots that were not in the previous one. Right now it runs when someone remembers, and an auction with a short window can open and close entirely between two sweeps.
  4. 04Keep every sweep in a history, to spot the plots that go unsold and drop in price at the second auction. That is the moment when land goes below market value, and without a history it goes unnoticed.
  5. 05Update the ERP with the plots that clear the first filter and with their status (to visit, visited, discarded, bidding), so the follow-up lives where deals are already managed instead of in a spreadsheet that gets rebuilt from scratch on every sweep.

Worth knowing

  • dependency

    The portal’s search form has no documentation and its parameters were worked out by poking at the live form. That turned up a behaviour written down nowhere: send the sort parameter alongside the status filter and the portal returns zero results with no warning. Without knowing that, the search looks empty when there are almost a hundred open auctions.

  • legal

    The gazette’s descriptions carry the property address and its occupancy status: whether someone lives there and under what title. The notice is public, but tipping it into a spreadsheet and keeping it is already processing personal data: that file should not travel beyond whoever decides on the purchase.

  • dependency

    The gazette offers no API: everything is read off its HTML, so the portal can change whenever it likes and leave this not working, without raising a single error. Rename one table label, say Appraisal to Appraised value, and the script keeps running and hands back that column empty; renumber the internal rural-land code, 507, and what comes out is a spreadsheet with zero rows, exactly as if there were no open auctions. Nobody notices until someone opens the file and misses something.

  • cost

    Sweeping the open auctions is about a hundred requests and takes a few minutes. The full history is another matter: 52 provinces by 6 states, plus one request per lot per auction. That goes from minutes to hours, and raises the odds of the portal cutting the requests off.

  • future

    Nothing bids automatically. Bidding means posting a deposit and signing, and the decision to go and see the land and enter the auction is still taken by a person with the spreadsheet in front of them.

Contact

Let's have a call. In 30 minutes I can tell you whether I can help.

Email address (enable JavaScript to reveal)LinkedIn