Skip to content
조회 수 19193 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

파이썬으로 captCha 분석하여 웹사이트 소스 가져오기

 

파이썬으로 captCha 분석 프로그램을 만들 수 있습니다.

그러나 captCha 분석은 비교적 복잡한 작업이며, 다양한 알고리즘과 기술이 필요합니다.

일반적으로 이미지 처리 및 인공지능 분야에서 활용되는 기술들을 사용하여 captCha 분석 프로그램을 개발합니다.

따라서, 만약 captCha 분석에 대한 경험이 부족하다면, 이미지 처리 및 인공지능 분야에서의 기술 및 알고리즘에 대한 학습이 필요할 수 있습니다.

그러나 Python은 이미지 처리 및 인공지능 분야에서 널리 사용되는 언어 중 하나이며, 다양한 라이브러리 및 프레임워크가 제공되고 있기 때문에 이러한 작업을 수행하는 데 사용할 수 있습니다.

이미지 처리에는 Pillow, OpenCV, Scikit-image 등의 라이브러리가 있으며, 인공지능 분야에는 TensorFlow, PyTorch, Keras 등의 프레임워크가 있습니다.

이러한 라이브러리 및 프레임워크를 사용하여 captCha 분석 프로그램을 구현할 수 있습니다.


 

import requests
from PIL import Image
import io
import pytesseract
 
# 테써렉트 위치
pytesseract.pytesseract.tesseract_cmd = r'G:/tesseract/tesseract.exe'
 
# 캡차 이미지 URL
captcha_url = 'https://chuksaro.nias.go.kr/hanwoori/captchaImg.do'
 
# 세션 생성
session = requests.Session()
 
# 인증서 다운로드
cert_url = 'https://www.nia.or.kr/common/key/nia-ca.crt'
cert_file = 'nia-ca.crt'
response = session.get(cert_url)
 
with open(cert_file, 'wb') as f:
    f.write(response.content)
 

# 캡차 이미지 다운로드
#response = session.get(captcha_url, verify=cert_file)

 
# 캡차 이미지 다운로드 개무시하기
 
response = session.get(captcha_url, verify=False) #인증서 검증을 비활성화하는 방법
 
# 캡차 이미지 다운로드 인증서 설치하기
#cert_file = "C:/python/py_code/automouse/ssl/_.nias.go.kr.crt"
#response = session.get(captcha_url, verify=cert_file)#신뢰할 수 있는 인증서를 설치하는 방법

captcha_img = Image.open(io.BytesIO(response.content))
 
# 캡차 이미지 처리
captcha_img = captcha_img.convert('L')
threshold = 127
table = []
for i in range(256):
    if i < threshold:
        table.append(0)
    else:
        table.append(1)
captcha_img = captcha_img.point(table, '1')
 
# pytesseract를 사용하여 캡차 이미지에서 텍스트 추출
captcha_text = pytesseract.image_to_string(captcha_img, config='--psm 10')

# 검색어 입력 폼에 값을 입력하여 검색
search_url = 'https://chuksaro.nias.go.kr/hanwoori/cowCntcInfo.do'
search_keyword = '002xxxxxxx'
response = session.post(search_url, data={'answer': captcha_text, 'search_keyword': search_keyword}, verify=cert_file)

with open('C:/python/py_code/automouse/result.txt', 'w', encoding='utf-8') as f:
    f.write(response.text)
   
# 검색 결과 출력
print(response.text)

 

 

 

 

로그인 후 댓글쓰기가 가능합니다.

?

List of Articles
번호 분류 제목 날짜 조회 수
757 컴퓨터잡담 Ghost용 배치 파일 작성 예 1 2009.11.24 8163
756 Server Google Chart API 이용하기 11 file 2013.04.10 20893
755 [Docs]스프레드시트 Google SpeadSheet 조건에 맞는 데이터만 참조하여 가져오기(importrange, Query) 1 file 2016.08.06 12961
754 [Docs]스프레드시트 Google Spreadsheet (Docs) 에서 우리은행 환율정보 이용하기 2014.11.11 29870
753 [Docs]스프레드시트 google spreadsheets html form post로 전달받기 file 2018.01.23 6882
752 [Docs]스프레드시트 Google 문서도구를 컴퓨터에 동기화 2015.11.18 4377
751 Excel Google 스프레드시트 함수 2014.10.04 7170
750 컴퓨터잡담 GoogleUpdate.exe 프로세스의 제거와 삭제 1 3 2011.06.16 9852
749 컴퓨터잡담 H734GP 공유기 시스템로그 중 >>> Send Offer / Receive Discover / 2023.06.04 52047
748 컴퓨터잡담 HMail Server 4.4.1 설치하기 2 2012.02.06 6904
747 컴퓨터잡담 hMailServer - 설치시 주의 핵심사항 1 2010.08.24 103068
746 Server HP XW6600 E5430 SPEC file 2016.11.06 4752
745 HTMLPHPMSQL html testing 2021.07.24 3740
744 컴퓨터잡담 HTML 엔티티(Entities) 2010.02.05 10845
743 컴퓨터잡담 HTML 엔티티(Entities) 2010.02.05 11190
742 WindowsTip html) Google Charts API 활용 그래프 만들기 2013.04.08 9611
741 Server html) 프레임 나누기 4 2013.03.02 10199
740 컴퓨터잡담 html_entity_decode [HTML엔티티를 => 특수문자로 변환 2 2010.01.30 16476
739 [Docs]스프레드시트 H열에 날짜가 10일 안으로 다가왔다면 메일을 발송하는 스크립트 2023.03.10 2272
738 WindowsTip IE 익스플로러 메뉴 바탕이 검정색으로 변했을경우 대처방법 2 2015.01.27 1644
Board Pagination Prev 1 ... 7 8 9 10 11 ... 46 Next
/ 46

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소