I'm new to Java, but decided to try my hand at making a little project happen. I'm trying to do some web scraping from a website, my issue is that although I can get the source material, I can't get the "inspect element" material to print out. I've looked over countless videos and searched on here as well but no matter what, I can only make a program print out the source material of this web page. I am trying to get the information out of a table, for pricing. The web page is "https://www.binance.com/trade.html?symbol=ZEC_BTC".
And my basic program is:
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.List;
import com.gargoylesoftware.htmlunit.*;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
public class main {
public static void main(String[] args) throws
FailingHttpStatusCodeException, MalformedURLException, IOException {
java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(java.util.logging.Level.OFF); /* comment out to turn off annoying htmlunit warnings */
WebClient webClient = new WebClient(BrowserVersion.CHROME);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.setJavaScriptTimeout(10000);
webClient.getOptions().setJavaScriptEnabled(true);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
webClient.getOptions().setTimeout(10000);
String url = "https://www.binance.com/trade.html?symbol=ZEC_BTC";
System.out.println("Loading page now: "+url);
HtmlPage page = webClient.getPage(url);
webClient.waitForBackgroundJavaScript(30 * 1000); /* will wait JavaScript to execute up to 30s */
String pageAsXml = page.asXml();
System.out.println(pageAsXml);
}
}
The idea here was that the program would load up the webpage, and then wait for the javascript to load before printing it. Any help would be VERY appreciated. I just need the javascript elements of the tables containing the prices to come printed out. Thank you.