How to Parse Data from a Table with No Obvious Class IDs using Javascript in Eclipse

I am trying to parse data from sites with a format similar to this one to retrieve surface observation for weather stations using Jscript (https://mesowest.utah.edu/cgi-bin/droman/meso_base_dyn.cgi?stn=KSLC&unit=0&timetype=GMT)

I have developed a script that allows me to take user input of any site and parse the title and a brief description, but I don’t appear to be able to use the element class to pull data from this table. I am not all that familiar with html, so any guidance here would be especially helpful!

Here is my code so far:

package com.climatedev.WebScraper;

//Import necessary packages
import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Document;
import java.net.*;
import java.io.*;
import java.util.Scanner;

//Pull site title and brief description to verify you are getting what you are expecting
public class WikiScraper {
    public static void main(String[] args) {
        Scanner address = new Scanner (System.in);
        System.out.println("Enter the complete url (including http://) of the site you would like to parse:");
        String html = address.nextLine();
        try {
            Document doc = Jsoup.connect(html).get();
            System.out.printf("Title: %s", doc.title());
            //Element table = doc.getElementByID("table");

        } catch (IOException e) {
            e.printStackTrace();
        }
        //Element table = doc.getElementByID("table");
        String contentText = Document.select("#mw-content-text > p").first().text();
    }

}

Leave a Reply

Your email address will not be published. Required fields are marked *