Urgent.News

What's breaking now, across thousands of outlets.

Tech

Tennis, football and basketball results as clean JSON, without a sports data contract

Sports data is one of those areas where the gap between "public information" and "affordable to obtain" is absurd. Scores and results are facts, printed in every newspaper. Getting them as structured data usually means either a five-figure contract with a rights holder, or writing your own scraper and maintaining it forever. If you are building a model, a scoreboard or a fantasy tool rather than…

Sports data is often inaccessible due to high costs, requiring expensive contracts or custom scrapers. However, there is a middle ground for building models, scoreboards, or fantasy tools. This article explores the nuances of sports data that many scrapers overlook.

Most scrapers inaccurately categorize match statuses as either upcoming, live, or finished. In reality, matches can be retired mid-set, abandoned at halftime, replayed, awarded, or decided by penalties. These scenarios require different treatments when building models. The author discovered this firsthand when their tennis scraper mislabeled live matches as cancelled, leading to seven incorrect labels on one day's worth of data.

When inferring data from samples, it's crucial to establish the correct mapping. In the case of tennis, codes 17 and 18 actually represent ongoing matches, not postponed or cancelled ones. The author's scraper was erroneously reporting live matches as cancelled, with instances of partially completed matches displaying as having no result.

Scores are not simply two integers. Tennis requires set scores and tiebreak points. A set ending 7-6 must consider the 7-4 tiebreak score, and a match at 6-6 in the first set must incorporate the live tiebreak count. A similar approach applies to basketball, which involves quarters and overtime periods. Ensuring these components add up correctly verifies the accuracy of your data mapping.

Football requires additional complexity with halves, extra time, and shootouts. A match ending 0-0, won 4-3 on penalties, might display as 1-0 due to the shootout points being absorbed into the final score. Deriving the first-half score from the total can lead to inaccurate results, particularly in shootout scenarios. It's better to leave these fields null rather than publishing incorrect data.

The author built three tailored scrapers for tennis, football, and basketball, each costing just $0.001 per match. One complete day of world football matches costs under $2, providing detailed information such as goals, assists, cards, substitutions, expected goals, and more. Importantly, every unmapped field remains preserved in the raw object, allowing for future expansion if needed. This approach ensures accurate and comprehensive sports data without relying on expensive contracts or intricate scraping techniques.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

How to find every Shopify store in a list of 10,000 domains

You have a list of domains. A conference attendee export, a directory scrape, a spreadsheet from a colleague. You want to know which of them run Shopify, which run WordPress, which have HubSpot…

  • Shopify stores can be identified by x-shopid in response headers
  • Cookies like shopifyy and utma indicate Shopify usage
  • URLs from cdn.shopify.com and Google Tag Manager scripts suggest Shopify sites

A source map is a claim, and nothing checks whether it is true

A source map is a claim about two files: that this position in the built output came from that position in a source file.

  • A source map links positions in output files to source files.
  • Validity of source maps can be questioned even when structurally sound.
  • Tool sourcemap-truth verifies source map accuracy.

More from Saturday 5 September →