0
I’m trying to create a database with stock histories extracted from a website. Below is an example of what I’m trying to do.
package com.gustavo.seleniumTest;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class seleniumTest {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "/home/gustavo/geckodriver");
WebDriver driver = new FirefoxDriver();
String valor;
driver.get("http://cotacoes.economia.uol.com.br/acao/cotacoes-historicas.html?codigo=PETR4.SA&size=200&page=1&period=");
valor = driver.findElement(By.xpath(".//*[@class='odd']")).getText();
System.out.println(valor);
}
}
I was able to create a robot with Selenium to insert values into a text box and press a button, but I’m having difficulty extracting values from a table or tag (HTML) and add to a variable or array.
Knows the Jsoup? This lib allows you to extract data from HTML
– renanvm