package com.xmxedu.demeter.main;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

import java.util.List;

/**
 * 简单地调用selenium来驱动chromedriver来进行任务爬取
 * @version 1.0.0
 */
public class SimpleSpider {
    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver", "demeter-preview/chromedriver");
        WebDriver driver = new ChromeDriver();
        driver.get(
            "http://www.neitui.me/index.php?name=neitui&handle=lists&fr=search&keyword=&kcity=%E6%9D%AD%E5%B7%9E");

        System.out.println("Page title is: " + driver.getTitle());

        WebElement jobDetials = driver.findElement(By.xpath("//*[@id=\"joblist\"]/div[4]/ul/li[8]"));

        System.out.println(jobDetials.getText());

        List<WebElement> jd = driver.findElements(
            By.cssSelector("#joblist > div.content.commentjobs.brjobs.topjobs > ul > li"));

        for (WebElement we: jd){
            WebElement jobDetail = we.findElement(By.xpath("//*[@id=\"joblist\"]/div[4]/ul/li[1]/div[2]/div[2]/div[1]/a"));
        }

        //Close the browser
        driver.quit();
    }
}

@@ -346,16 +346,17 @@
 args) %7B%0A
+%0A
         
@@ -477,24 +477,45 @@
 meDriver();%0A
+%0A        try %7B%0A%0A%0A    
         driv
@@ -522,16 +522,20 @@
 er.get(%0A
+    
         
@@ -639,24 +639,60 @@
 5%25B7%259E%22);%0A%0A
+            Thread.sleep(2000);%0A    
         Syst
@@ -755,158 +755,8 @@
     
-    WebElement jobDetials = driver.findElement(By.xpath(%22//*%5B@id=%5C%22joblist%5C%22%5D/div%5B4%5D/ul/li%5B8%5D%22));%0A%0A        System.out.println(jobDetials.getText());%0A%0A
     
@@ -801,29 +801,16 @@
 lements(
-%0A            
 By.cssSe
@@ -878,24 +878,60 @@
 l %3E li%22));%0A%0A
+            Thread.sleep(2000);%0A    
         for 
@@ -948,15 +948,21 @@
 t we
+ 
 : jd)
+ 
 %7B%0A
+    
     
@@ -1014,87 +1014,146 @@
 (By.
-xpath(%22//*%5B@id=%5C%22joblist%5C%22%5D/div%5B4%5D/ul/li%5B1%5D/div%5B2%5D/div%5B2%5D/div%5B1%5D/a%22));%0A
+className(%22jobnote-l%22));%0A                String url = jobDetail.getAttribute(%22href%22);%0A                System.out.println(url);%0A   
         
 %7D%0A%0A 
@@ -1152,11 +1152,16 @@
     
+ 
 %7D%0A%0A
+    
     
@@ -1188,24 +1188,28 @@
 ser%0A        
+   
+ 
 driver.quit(
@@ -1211,16 +1211,116 @@
 quit();%0A
+        %7Dcatch (Exception e)%7B%0A            e.printStackTrace();%0A            driver.quit();%0A        %7D%0A
     %7D%0A%7D%0A

implement logic code to fetch url of job