본문 바로가기

Python_Beginer/Note

Python 수강 노트 5

반응형

< 190303 >

- driver.get('site 주소')

- driver.find_element_by_name().send_keys() : name으로 검색한 부분에 키값을 입력한다.

- driver.find_element_by_id().send_keys() : id로 검색한 부분에 키값을 입력한다.

- driver.find_element_by_xpath().click() : 버튼으로 눌러서 검색하여 클릭한다.

- strong.tit_subject : strong에 class가 tit_subject를 가져온다.(css -> . = class / # = ID)

- driver.implicitly_wait() : 시간 벌기

- driver.quit() : 크롬 종료

- 각 사이트 분석 기법

< 지메일 로그인 사이트 분석 기법 >

- 지메일 로그인 Site 주소

https://accounts.google.com/ServiceLogin/identifier?service=mail&passive=true&rm=false&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1&flowName=GlifWebSignIn&flowEntry=AddSession

- ID Html 분석

<input type="email" class="whsOnd zHQkBf" jsname="YPqjbf" autocomplete="username"

spellcheck="false" tabindex="0" aria-label="이메일 또는 휴대전화" name="identifier"

autocapitalize="none" id="identifierId" dir="ltr" data-initial-dir="ltr" data-initial-value="" badinput="false">

- PW Html 분석

<input type="password" class="whsOnd zHQkBf" jsname="YPqjbf" autocomplete="current-password"

spellcheck="false" tabindex="0" aria-label="비밀번호 입력" name="password"

autocapitalize="off" dir="ltr" data-initial-dir="ltr" data-initial-value="" badinput="false">

- ID next 클릭 분석(Xpath)

next 버튼 sample 1

//*[@id="identifierNext"]/div[2]

next 버튼 sample 2

//*[@id="identifierNext"]/content/span

next 버튼 sample 3

//*[@id="identifierNext"]/content

- PW next 클릭 분석(Xpath)

next 버튼 sample 1

//*[@id="passwordNext"]/div[2]

next 버튼 sample 2

//*[@id="passwordNext"]/content/span

next 버튼 sample 3

//*[@id="passwordNext"]/content


< 다음메일 로그인 사이트 분석 기법 >

- 다음메일 로그인 Site 주소

https://logins.daum.net/accounts/loginform.do?url=https%3A%2F%2Fmail.daum.net%2F

- ID Html 분석

<input type="email" id="id" name="id" value="" class="tf_g" style="ime-mode:disabled;">

- PW Html 분석

<input type="password" id="inputPwd" name="pw" class="tf_g" maxlength="32" autocomplete="off" style="ime-mode:disabled;">

- 로그인 버튼 분석(Xpath)

로그인 버튼 sample 1

//*[@id="loginBtn"]


< 네이버 로그인 사이트 분석 기법 >

- 네이버 로그인 Site 주소

https://nid.naver.com/nidlogin.login?mode=number

- 일회용 비밀번호 입력 Html 분석

<input type="text" id="disposable_num" name="key" maxlength="20" placeholder="일회용 로그인 번호" class="int" autocomplete="off">

- 로그인 버튼 분석(Xpath)

로그인 버튼 sample 1

//*[@id="frmNIDLogin"]/fieldset/span/input

- 네이버 메일 버튼 분석(Xpath)

메일 버튼 sample 1

//*[@id="PM_ID_ct"]/div[1]/div[2]/div[1]/ul[1]/li[1]/a/span[1]

- 스크래피를 이용해서 크롤러를 만드는 과정

1. 크롤링할 아이템을 설정합니다.

2. 실제 크롤링할 스파이더를 만듭니다.

3. 크롤링할 사이트와 크롤링 규칙을 설정한다.(정규식)

4. 스파이더의 종류에 따른 몇 가지 설정을 추가합니다. 크롤링할 URL의 패턴 등을 설정합니다.

5. HTML 문서를 파싱한 후 크롤러가 실행할 작업을 정의합니다.

6. 크롤러를 실행합니다.

- Framework를 만들기

scrapy startproject 프로젝트명

- tree 구성보기

tree 프로젝트명

- items.py : 내가 가져와야 될 것을 정의하는 파일

- scrapy genspider : 스파이더를 생성해주는 명령어

- spider 종류에

basic : 기본적인 크롤러

crawl : 재귀적으로 탐색 크롤러

xmlfeed : xml 피드를 크롤러

csvfeed : xmlfeed 크롤러랑 비교하면 각 행을 크롤링

scrapy genspider -t crawl book_crawl hanbit.co.kr

- scrapy crawl <크롤러이름> -o <출력파일이름>

반응형

'Python_Beginer > Note' 카테고리의 다른 글

Python 수강 노트 7  (0) 2019.03.15
Python 수강 노트 6  (0) 2019.03.15
Python 분석 방법 2  (0) 2019.03.03
Python 분석 방법  (0) 2019.03.03
Python 수강 노트 4  (0) 2019.02.24