こんにちは、私はできる別のサイトからデータを抽出しようとしていますが、問題は、達成できない目的の形式でデータを抽出したいということです。どうすれば目標を達成できますか
ここに私がした私のコードがあります
import com.gargoylesoftware.htmlunit.BrowserVersion;
import java.util.StringTokenizer;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.support.ui.Select;
import java.sql.*;
public class Getdata2 {
Statement st=null;
Connection cn=null;
public static void main(String args[]) throws InterruptedException, ClassNotFoundException, SQLException {
WebDriver driver = new HtmlUnitDriver(BrowserVersion.getDefault());
String sDate = "27/03/2014";
String url="http://www.upmandiparishad.in/commodityWiseAll.aspx";
driver.get(url);
Thread.sleep(5000);
new Select(driver.findElement(By.id("ctl00_ContentPlaceHolder1_ddl_commodity"))).selectByVisibleText("Jo");
driver.findElement(By.id("ctl00_ContentPlaceHolder1_txt_rate")).sendKeys(sDate);
Thread.sleep(3000);
driver.findElement(By.id("ctl00_ContentPlaceHolder1_btn_show")).click();
Thread.sleep(5000);
WebElement findElement = driver.findElement(By.id("ctl00_ContentPlaceHolder1_GridView1"));
String htmlTableText = findElement.getText();
// do whatever you want now, This is raw table values.
htmlTableText=htmlTableText.replace("S.No.DistrictMarketPrice","");
System.out.println(htmlTableText);
driver.close();
driver.quit();
}
}
このようにデータを抽出したい
1 Agra Achhnera NIL
2 Agra Agra NIL
3 Agra Fatehabad NIL
4 Agra FatehpurSikri NIL
5 Agra Jagner NIL
6 Agra Jarar NIL
7 Agra Khairagarh NIL
8 Agra Shamshabad NIL
9 Aligarh Atrauli NIL
10 Aligarh Chharra NIL
11 Aligarh Aligarh 1300.00
12 Aligarh Khair 1300.00
13 Allahabad Allahabad NIL
14 Allahabad Jasra NIL
15 Allahabad Leriyari NIL
16 Allahabad Sirsa NIL
17 AmbedkarNagar Akbarpur NIL
18 Ambedkar Nagar TandaAkbarpur NIL
どうすれば目的の出力を達成できますか
前もって感謝します