```yaml
product: AlterLab
title: "Java Web Scraping: TV Show Data from Web Pages | AlterLab"
comparison_context: "AlterLab is an alternative to Firecrawl, ScrapingBee, and Bright Data."
source_url: https://alterlab.io/answers/java-web-scraping-tv-show-data
```

# Web Scraping in Java: Getting TV Show Data from Web Pages

## Short answer

### How do you get TV show information from web pages into Java?

Check for a public API first, such as TVmaze, which returns show data as JSON. If none covers your fields, fetch the page HTML and parse it with jsoup using CSS selectors, then map the results into Java objects. For JavaScript-rendered pages, fetch rendered HTML through AlterLab and parse it with jsoup.

## Step by step

1. 1
   ### Look for an API
   Structured APIs are faster and more stable than HTML parsing. Use them whenever they provide the fields you need.
2. 2
   ### Add jsoup
   Add the org.jsoup:jsoup dependency with Maven or Gradle.
3. 3
   ### Fetch and select
   Load the page with Jsoup.connect(url).get() and select elements with CSS selectors such as `h1.show-title`.
4. 4
   ### Map to objects
   Convert each selected element into a record or POJO so the rest of your program works with typed data.

## Example

Java

```
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

public class ShowScraper {
    record Show(String title, String network) {}

    public static void main(String[] args) throws Exception {
        Document doc = Jsoup.connect("https://example.com/shows/123").get();
        Show show = new Show(
            doc.selectFirst("h1.show-title").text(),
            doc.selectFirst(".network").text()
        );
        System.out.println(show);
    }
}
```

## Frequently Asked Questions

### Is jsoup enough for every site?

jsoup parses HTML but does not run JavaScript. For pages that build their content in the browser, fetch the rendered HTML first and pass it to Jsoup.parse().

### How do I avoid overloading the site?

Add a delay between requests, cache pages you have already fetched and respect robots.txt. Fetch only the pages you need.

## Read the full guide

[Java web scraping guide](https://alterlab.io/java-web-scraping-guide)

## Related answers

[Scraping a Web Page in C# with HtmlAgilityPack](https://alterlab.io/answers/csharp-htmlagilitypack-scrape-web-page)[Ruby HTML Parsing Gems Like Cheerio for Node.js](https://alterlab.io/answers/ruby-html-parsing-gem-like-cheerio)

## Try it with AlterLab

Send a URL, get the page back as HTML, markdown or JSON. Rendering, proxy rotation and retries are handled for you.

[View API docs](https://alterlab.io/docs/api/rest)

## Your first scrape. Sixty seconds.

Up to 5,000 free requests — about 5,000 direct fetch, 500 managed sessions or 250 full browser rendering requests. No credit card. 
Just a POST request.

terminal

curl -X POST https://api.alterlab.io/v1/scrape \

-H "X-API-Key: YOUR_KEY" \

-H "Content-Type: application/json" \

-d '{"url": "https://example.com", "formats": ["markdown"]}'

[Start building free](https://alterlab.io/signin)

No credit card required · Up to 5,000 free requests (about 5,000 direct fetch, 500 managed sessions or 250 full browser rendering requests) · Balance never expires