0

below I have some Jsoup code, and im just trying to just establish scraping from coinbase, but for some reason it throws the error in the title, does anyone know what im doing wrong?

import java.io.IOException;
import org.jsoup.*;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

public class Main {

    public static void main(String[] args) 
    {
    
        try {
            Document doc = Jsoup.connect("https://www.coinbase.com/dashboard").get();
        
            System.out.println(doc.outerHtml());
        
            System.out.println();
        }catch(IOException e)
        {
        
            e.printStackTrace();
                
        }
        
    }
}
  • Possibly related: [How to solve java.lang.NoClassDefFoundError?](https://stackoverflow.com/q/17973970) – Pshemo Oct 31 '20 at 22:40
  • Download the JSoup [**JAR** File](https://jsoup.org/download), and include that file in your ***CLASSPATH*** `Environment Variable`. If you are using **Maven** or **Gradle** follow the directions on that page. – Y2020-09 Nov 01 '20 at 11:35
  • worth also mentioning coinbase and coinbase-pro have back end APIs. Just look online for their respective APIs and you'll find them relatively quickly – Rob Evans Nov 02 '20 at 14:20

1 Answers1

0

If you're using an IDE like IntelliJ Community Edition, you can create a Gradle project. Copy the below into build.gradle and update the value of group

plugins {
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.jsoup:jsoup:1.10.2'
}

Click the gradle tab (right hand side typically), then the "refresh" button, or go to the in-built terminal (Alt+F12) and perform gradle clean build. Either of these processes will trigger the download of the dependencies to the application.

You can also add gradle to your existing project with gradle init assuming you have gradle installed. You may need to restart the IDE for the IDE to recognise the newly added configuration.

Using a build tool like this makes importing library dependencies a far simpler task.

Now if you try running your main method in the IDE, it should work.

Rob Evans
  • 2,822
  • 1
  • 9
  • 15