Crawling setting 


프로젝트를 진행 하다보면 테스트 할 데이터가 필요합니다.

데이터를 직접 만들기엔 전문성이 떨어져 비영리적으로 사용할 목적으로 

다른 사이트에서 데이터를 빌려(?) 오는 크롤링을 사용해야합니다.


사용할 프레임워크는 Spring.

아래는 메이븐pom.xml 을 이용하여 라이브러리를 받아왔습니다.



        
            org.jsoup
            jsoup
            1.11.2
        
        
            com.googlecode.json-simple
            json-simple
            1.1.1
        
        
        
            net.sourceforge.htmlunit
            htmlunit
            2.29
        
        
        
            org.seleniumhq.selenium
            selenium-java
            3.3.1
        
         
        
            io.github.bonigarcia
            webdrivermanager
            1.6.0
            
                
                    com.google.guava
                    guava
                
            
        


프로젝트에 코드 적용 전 테스트를 위해 JUnit을 이용하여 기능 작동 여부를 테스트 할 건데요

그 전에 자신에게 맞는 브라우저를 선택 하여 드라이버를 설치 한 후 test/resource에 넣어 경로를 복사해둡니다. 


 브라우저

 주소 

 Chrome 

 https://sites.google.com/a/chromium.org/chromedriver/downloads

 Egdge 

 https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

 Firefox

 https://github.com/mozilla/geckodriver/releases

 Safari

 https://webkit.org/blog/6900/webdriver-support-in-safari-10/


package org.yogiyo.app.crawling;

import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;



public class CrawlingTest {

    private WebDriver driver;

    @Before(value="mainTest")
    public void setUp()throws Exception{
        System.setProperty("webdriver.chrome.driver", "/Yogiyo/src/test/resources/driver/chromedriver");
        // 다운받은 ChromeDriver 위치를 넣어준다.
        driver = new ChromeDriver(); // Driver 생성
    }
    @After(value="mainTest")
    public void tearDown()throws Exception{
        driver.quit();  // Driver 종료
    }
    @Test
    public void mainTest() throws Exception{
        System.out.println("테스트");
    }
}

위와 같이 테스트를 완료 했습니다.

다음 포스팅은 크롤링을 하는 방법에 대해서 포스팅을 해보겠습니다.

+ Recent posts