250x250
반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 독후감
- Django
- todolist
- UPSERT
- 서울로가자
- Git
- 헬레나크로닌
- MySQL
- 공작과개미
- db
- 일일투자금액
- 지방사람이보는서울사람
- php
- Python
- 성선택
- 옹졸함
- 클라우드
- linux명령어
- 중용
- Face Detection
- 나만의주식5법칙
- 훌륭한모국어
- 네인생우습지않다
- delete
- 다산의마지막습관
- ChatGPT
- OpenCV
- 비밀번호변경
- 꼭읽어봐야할책
- git 업로드
Archives
- Today
- Total
Terry Very Good
[javascript] 반복문 활용해서 특정 문자가 있는 tag 찾기( for | includes | 본문
RPA/Crawling(Elements 접근 및 사용)
[javascript] 반복문 활용해서 특정 문자가 있는 tag 찾기( for | includes |
테리베리 2022. 4. 15. 17:56728x90
반응형
javascript for문
for(a = 1; a <= 10; a++){
document.getElementById('result0').getElementsByTagName('div')[a];
}
javascript 특정 문자가 포함되는 지 확인하기(return값은 true false)
console.log(str.includes('java'));
https://mjob.sarangbang.com/employ/employDetail.html?uid=2203040027300001
에서, 채용문의라는 텍스트가 포함된 div 찾는 법
for(a = 1; a <= 20; a++){
console.log(document.getElementById('result0').getElementsByTagName('div')[a].textContent.includes('채용문의'));
}
이제 if문을 활용해서 만약 "채용문의"라는 문자가 있다면, 전화번호를 따오도록 만들어보자
참고로 전화번호 따오는 코드는
document.getElementById('result0').getElementsByTagName('div')[18].getElementsByTagName('dd')[1].getElementsByTagName('a')[0].href;
이다.
728x90
반응형
'RPA > Crawling(Elements 접근 및 사용)' 카테고리의 다른 글
[javascript] 전자조달시스템(srm.kepco.net) 입찰공고 크롤링 (0) | 2022.04.15 |
---|