티스토리 뷰
광고
광고
package sele;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Daum {
public static void main(String[] args) {
Daum selTest = new Daum();
selTest.crawl();
}
//WebDriver
private WebDriver driver;
static WebDriverWait wait;
//Properties
public static final String WEB_DRIVER_ID = "webdriver.chrome.driver";
public static final String WEB_DRIVER_PATH = "C:\\sele\\chromedriver.exe";
//크롤링 할 URL
private String base_url;
public Daum() {
super();
//System Property SetUp
System.setProperty(WEB_DRIVER_ID, WEB_DRIVER_PATH);
//Driver SetUp
driver = new ChromeDriver();
base_url = "https://www.daum.net";
}
public void crawl() {
try {
//get page (= 브라우저에서 url을 주소창에 넣은 후 request 한 것과 같다)
driver.get(base_url);
System.out.println(driver.getPageSource());
driver.findElement(By.xpath("//*[@id=\"inner_login\"]/a[1]")).click();
String user_id = "";
String user_passwd = "";
driver.findElement(By.id("id_email_2")).sendKeys(user_id);
driver.findElement(By.id("id_password_3")).sendKeys(user_passwd);
driver.findElement(By.xpath("//*[@id=\"login-form\"]/fieldset/div[8]/button[1]")).click();
} catch (Exception e) {
e.printStackTrace();
} finally {
//driver.close();
}
}
}
자바로 다음 로그인 하는 소스 코드 이다. 카카오 로그인 버튼 클릭해서 카카오 계정으로 로그인 하는거다.
'자바(Java) > 자바 셀레니움' 카테고리의 다른 글
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/compress/archivers/zip/ZipFile (0) | 2021.12.21 |
---|---|
자바 랜덤 문자+숫자 8자리 (0) | 2021.12.21 |
자바 셀레니움 네이버 메인 페이지 가져오기 (0) | 2021.12.20 |
자바 셀레니움 java selenium cannot find Chrome binary (0) | 2021.05.21 |
자바 셀레니움 Java Selenium - 2 (0) | 2021.05.20 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- XE
- 인포믹스
- C
- 포인터
- 자바 smtp
- 파이썬
- 프로씨
- C언어
- 플러터
- xe addon
- EC
- webix
- 자바
- MySQL
- 파싱
- ocajp
- 문자열
- KG
- JDBC
- 라이믹스 모듈
- esql
- proc
- 오라클
- xe애드온
- 스크래핑
- 이클립스
- php
- ocjap
- Python
- XE3
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
글 보관함