You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.ErrorHandler;
import org.openqa.selenium.remote.RemoteWebDriver;
import com.machinepublishers.jbrowserdriver.JBrowserDriver;
import com.machinepublishers.jbrowserdriver.Settings;
import com.machinepublishers.jbrowserdriver.Timezone;
import com.machinepublishers.jbrowserdriver.UserAgent;
public class Example {
public static void main(String[] args) throws MalformedURLException {
File userDataDirectory = FileUtils.getTempDirectory();
// You can optionally pass a Settings object here,
// constructed using Settings.Builder
JBrowserDriver driver = new JBrowserDriver(Settings.builder()
.ajaxResourceTimeout(100000)
.ajaxWait(100000)
.headless(false)
.csrf()
.logJavascript(true)
.loggerLevel(Level.ALL)
.userAgent(UserAgent.CHROME)
.userDataDirectory(userDataDirectory )
.timezone(Timezone.AMERICA_NEWYORK)
.build());
// This will block for the page load and any
// associated AJAX requests
driver.get("https://www.tradingview.com/chart/USDCNH/fxN4XIA0-USD-CNH-Sell-Idea/");
System.out.println(driver.getCapabilities());
// You can get status code unlike other Selenium drivers.
// It blocks for AJAX requests and page loads after clicks
// and keyboard events.
//System.out.println(driver.getStatusCode());
// Returns the page source in its current state, including
// any DOM updates that occurred after page load
String pageSource = driver.getPageSource();
//System.out.println(pageSource);
Document doc = Jsoup.parse(pageSource);
Element masthead = doc.select(".tv-chart-view__symbol-link").first();
//System.out.println(masthead);
String text = doc.select(".tv-chart-view").html(); // .attr("data-options") "An example link"
//js-chart-view
//String linkHref = link.attr("href"); // "http://example.com/"
String unescapeHtml = StringEscapeUtils.unescapeHtml(text);
//System.out.println(pageSource);
//tv-chart-view__symbol-link
// Close the browser. Allows this thread to terminate.
driver.quit();
System.out.println("finished");
}
}
The text was updated successfully, but these errors were encountered:
Hello,
I am using the below code in an attempt to render, correctly, the following url:
ttps://www.tradingview.com/chart/USDCNH/fxN4XIA0-USD-CNH-Sell-Idea/
However, the chart never renders.
Any ideas as to what is wrong?
Code
The text was updated successfully, but these errors were encountered: