技术交流爬虫技术
QQ:1761067247
public static void main(String[] args) throws Exception {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Mechrevo\\Desktop\\chromedriver.exe");
WebDriver webDriver = new ChromeDriver();
webDriver.get("https://auth.alipay.com/login/index.htm");
Thread.sleep(60000);
webDriver.manage().window().maximize();
// 拿到数据存数据库链接
String urls = "http://************/";
while (true) {
Thread.sleep(15000);
webDriver.navigate().to("https://mbillexprod.alipay.com/enterprise/tradeListQuery.htm");
Thread.sleep(15000);
String currentUrl = webDriver.getCurrentUrl();
if (currentUrl.equals("https://mbillexprod.alipay.com/enterprise/tradeListQuery.htm")) {
try {
Thread.sleep(15000);
WebElement day30 = webDriver
.findElement(By.xpath("(//div[@class='quickTimeSelectWrapper___1nv7h']/div[4])"));
day30.click();
Thread.sleep(15000);
WebElement sell = webDriver
.findElement(By.xpath("(//div[@class='ant-tabs-nav ant-tabs-nav-animated']/div[8])"));
sell.click();
Thread.sleep(15000);
// 交易个数
WebElement table = webDriver.findElement(By.xpath("(//div[@class='ant-table-body']/table)"));
List<WebElement> rows = table.findElements(By.xpath("(//tbody/tr)"));
if (rows.size() > 0) {
int num = rows.size() / 2;
for (int i = 1; i <= num; i++) {
Thread.sleep(500);
WebElement date = webDriver.findElement(By.xpath("(//tbody[@class='ant-table-tbody']/tr["
+ i + "])/td[@class=' ant-table-column-sort']/span[2]/span/span[1]"));
WebElement time = webDriver.findElement(By.xpath("(//tbody[@class='ant-table-tbody']/tr["
+ i + "])/td[@class=' ant-table-column-sort']/span[2]/span/span[2]")