반응형
Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
31 |
Tags
- docker
- WebLogic
- Redis Sentinel
- docker compose mysql
- ChannelPipeline
- KAFKA
- grafana
- argo cd
- Airflow
- Spring Open Feign
- netflix oss
- JPA
- docker-compose
- spring boot redis
- Hibernate
- cassandra
- jmeter
- MySQL
- Docker Compose
- coalesce
- mybatis
- Selenium
- vue.js
- spring boot
- Netty
- QueryDSL
- weblogic 10
- redis
- RabbitMQ
- spring cloud
Archives
- Today
- Total
IT.FARMER
Python Web Crawler / selenium 본문
반응형
Web Crawler Library
Python Library | 특징 |
---|---|
Selenium | 웹테스팅 도구 프레임웍 브라우저와 드라이버로 연결되어 브러우저에서 하는 작업들을 자동화 시킬수 있다. 웹인터페이스로 동작하며, phantomJS와 호환 가능 |
PhantomJS | 웹테스팅 도구 프레임웍 , 화면이 존재 하지 않는 특징 웹표준을 따르는 Headless Webkit 자바스크립트를 사용 할 수 있으며 , DOM, CSS JSON, SVG등 컨트롤 가능 |
Beautifulsoup | HTML 을 쉽게 파싱하여 사용 할 수 있는 특징 HTML과 XML 파일에서 데이터를 읽어내는 라이프러리 |
ChromeDriver
Selenium API
예제
import
time
from
selenium
import
webdriver
from
bs4
import
BeautifulSoup
import
xlrd
from
selenium.webdriver.common.by
import
By
from
selenium.webdriver.support.ui
import
WebDriverWait
from
selenium.webdriver.support
import
expected_conditions as EC
path
=
"C:/Users/skan/Downloads/chromedriver_win32/chromedriver.exe"
driver
=
webdriver.Chrome(path)
# 페이지 접속
#driver.implicitly_wait(10)
#페이지의 제목을 체크하여 'Google'에 제대로 접속했는지 확인한다
#assert "Google" in driver.title
#assert "Naver" in driver.title
# Element Find
userIdElem
=
driver.find_element_by_id(
"userId"
)
userPasswordElem
=
driver.find_element_by_id(
"userPw"
)
# Value Setting
userIdElem.send_keys(
"userId"
)
userPasswordElem.send_keys(
"password"
)
# page submit
form
=
driver.find_element_by_id(
'frm'
)
form.submit();
# Report page 이동
# driver.implicitly_wait(10)
# iframe 접속
driver.switch_to.frame(driver.find_element_by_tag_name(
'iframe'
))
try
:
element
=
WebDriverWait(driver,
3
).until(EC.presence_of_element_located((By.
ID
,
"iframeReport"
)))
except
Exception as ex:
print
(
'element = '
, ex)
tableElem
=
driver.find_element_by_id(
'grid'
)
tbodyElem
=
tableElem.find_elements_by_tag_name(
'tbody'
)
for
tbodyData
in
tbodyElem:
print
(
'tbody '
, tbodyData.text)
반응형