본문 바로가기
반응형

● 크롤링, 자동화/Selenium17

colab에서 selenium 사용하는 법 Colab에선 별도로 chrome webdriver를 설치해줘야함 !pip install selenium !apt-get update !apt install chromium-chromedriver from selenium import webdriver from urllib.request import urlopen from bs4 import BeautifulSoup as bs from urllib.parse import quote_plus from selenium.webdriver.common.keys import Keys import time url = 'https://search.naver.com/search.naver?where=image&sm=tab_jum&query=' kword = input(.. 2021. 8. 12.
Google Colab, Google drive와 연동하기 import os, sys from google.colab import drive # drive.mount('/content/mnt') # drive 파일 경로 nb_path = '/content/notebooks' os.symlink('/content/mnt/My Drive/Colab Notebooks', nb_path) sys.path.insert(0, nb_path) 솜씨좋은장씨 세상 모든 개발 관련 지식을 담아보자! somjang.tistory.com 2021. 8. 12.
[에러해결] Google Colab error : 'chromedriver' executable needs to be in PATH 원인 : It is probably due to an update from Selenium 해결방법 : apt-get update 참고자료 : 1. Stackoverflow 2021. 8. 12.
[오류해결] INTEL MKL ERROR: 지정된 모듈을 찾을 수 없습니다. mkl_intel_thread.1.dll.Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.1.dll. 상황 : 크롤링py파일을 pyinstaller로 exe파일로 생성함 하지만 exe파일을 실행하니 제목과 같은 오류 2가지가 발생 오류명 : INTEL MKL ERROR: 지정된 모듈을 찾을 수 없습니다. mkl_intel_thread.1.dll. Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.1.dll. 원인 : 프로그램이 라이브러리 경로에서 mkl 라이브러리 파일을 찾을 수 없음을 의미 해결방법 : "mkl_"로 시작하는 파일을 python.exe 루트에 복사하여 문제를 해결 anaconda3 folder에 있는 3가지 파일(하단) - mkl_core.1.dll - mkl_def.1.dll - mkl_intel_thread.1.dll 을 exe파일이 위치한.. 2021. 8. 11.
[jupyter notebook] pyinstaller로 exe파일 만들기 (ipynb -> py 변환) 개요 1. ipynb를 py로 변환하기 2. pyinstall로 exe파일 만들기 3. exe 후 정상적으로 작동하지 않는다면? 1. ipynb를 py로 변환하기 환경 : jupyter notebook # pyinstaller를 설치 pip install pyInstaller # 확장자 변환하기 !jupyter nbconvert --to script cio_korea.ipynb 2. pyinstall로 exe파일 만들기 환경 : Anaconda Prompt # pyinstaller 설치 conda install pyinstaller # exe로 만들 파일이 위치한 폴더로 이동 cd dev # exe 파일 만들기 pyinstaller cio_korea.py # cio_korea.py는 exe파일로 만들 파.. 2021. 8. 11.
Selenium Dropdown, Commbo box 선택하는 방법 Selenium Dropdown, Commbo box 선택하는 방법은 의외로 간단하다. from selenium import webdriver b = webdriver.Firefox() b.find_element_by_xpath("여기에 Copy Xpath 넣기").click() 끝. 2021. 6. 2.
Selenium 에서 헤더 User-Agent 값 수정하기 문제점 : Python과 Selenium을 활용해서 크롤링 하는 도중에 한 사이트가 오직 IE에서만 작동 해결책 : 헤더값에 User-Agent 값을 IE의 값으로 바꿔주면 된다 방법 : from selenium import webdriver import Config options = webdriver.ChromeOptions() options.add_argument("user-agent=Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") driver = webdriver.Chrome(executable_path=Config.CONFIG['CHROMEPATH'],options=options) driver.get('') https:.. 2021. 5. 19.
NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".p"} (Session info: chrome=90.0.4430.212) NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".p"} (Session info: chrome=90.0.4430.212) 원인 : 페이지 로드시 .p가 생성되지 않으므로 NoSuchElementException에러가 발생 해결법 : 셀레니움의 대기(Waits)기능을 이용해서 해결 p_tag = WebDriverWait(browser,timeout=5).until(EC.presence_of_element_located((By.TAG_NAME, "p"))) print("p태그를 찾았습니다.") https://workingwithpython.com/sele.. 2021. 5. 19.
[beautifulsoup, selenium] 인스타그램 이미지 크롤링해보자! 1. 사전작업 크롬브라우저 버전 체크하기 크롬 브라우저 > 설정 > 좌측하단의 크롬 정보 클릭해서 확인 이제 버전에 맞는 크롬 드라이버를 하단의 사이트에서 다운로드받자. ChromeDriver - WebDriver for Chrome - Downloads Current Releases If you are using Chrome version 91, please download ChromeDriver 91.0.4472.19 If you are using Chrome version 90, please download ChromeDriver 90.0.4430.24 If you are using Chrome version 89, please download ChromeDriver 89.0.4389.23 If y.. 2021. 5. 4.
[잔재미] 셀레니움 이미지 크롤링 1. Jupyter Notebook에서 셀레니움 설치 !pip install selenium 2. 크롬 드라이버 다운받기 본인 브라우저 사양에 맞는 것을 다운 ChromeDriver - WebDriver for Chrome WebDriver for Chrome sites.google.com 3. 셀레니움 공홈에서 예시 코드 복붙해서 실행하기 2. Getting Started — Selenium Python Bindings 2 documentation 2.2. Example Explained The selenium.webdriver module provides all the WebDriver implementations. Currently supported WebDriver implementations a.. 2021. 2. 8.
구글 로그인, 메일 보내기 자동화 (selenium, webdriver, actionchains) 2020. 5. 6. 실습 전 할 것 1. 내 크롬브라우저에 맞는 크롬드라이버를 다운 2. 실습하고자 하는 파이썬 파일에 해당 크롬 드라이버를 넣고 실습시작 => 실습(실행)파일과 동일한 루트에 넣으면 따로 루트 지정필요없이 => driver = webdriver.Chrome()만으로 실행가능 다음 코드를 입력 from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.action_chains import ActionChains # 쭉 연결할 수 있게함 import time driver = webdriver.Chrome() url = "https://google.com.. 2020. 11. 8.
selenium 자동화 수집하기 2020. 5. 6 오류 from selenium import webdriver driver = webdriver.Chrome() 까지 입력하자 WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home오류 해결 검색진행 내 크롬브라우저환경에 맞는 chromedriver다운 후 해당 주소 복사 정상 실행 크롬드라이버의 위치를 삽입 후 정상 실행 from selenium import webdriver driver = webdriver.Chrome(executable_path=r"C:\dev_python\Web.. 2020. 11. 8.
Anaconda 다운로드 받기, Jupyter Notebook 설치하기 Anaconda Download아나콘다(Anaconda)를 다운받아보자 Anaconda | Individual EditionAnaconda's open-source Individual Edition is the easiest way to perform Python/R data science and machine learning on a single machine.www.anaconda.com위 사이트로 접속한 뒤 스크롤을 내려보면 하단과 같은 창이 나타난다.이 중 본인의 OS에 해당되는 설치파일을 다운받으면 끝! Jupyter Notebook InstallAnaconda를 설치했으니 이제는 쥬피터노트북(Jupyter Notebook)을 설치해보자!Project JupyterThe Jupyter Noteb.. 2020. 11. 8.
네이버 카페 크롤 - 01 로그인 하기 목표 : 네이버 카페 특정 키워드 검색 결과 받아오기 순차 1. 로그인 - time.sleep(20) 수동으로 진행 2. 카페 이동 3. 검색어 검색 4. 결과 출력 깃허브 2020. 8. 30.
[나도코딩] 가격비교 사이트, 나도 만들 수 있다! 잼있게 파이썬으로 하는 크롤러 제작 [Crawling] 검색엔진이 크롤링을 이용함 구글봇, 빙봇 이 봇들이 여러 사이트를 돌아다니면서 사이트에 연결된 페이지를 복사해서 DB에 복사해서 검색이 잘되도록 분류함 크롤링 1. 정보를 수집 후 가공해서 사용 : 스크래핑 2. 크롤링 봇을 이용한 복사 수집 크롤러가 읽어도 되는 정보와 읽지 않았으면 하는 정보를 Robots.txt에 기재함. 크롤러는 Robts.txt를 따르지만 따르지 않는 악성 크롤러도 있다. 실습 모듈 : 복잡한 기능을 편리하게 만든 함수 (import random) pip : 모듈을 다운받기 위해 pip라는 명령어를 사용 셀리니움 : 브라우저를 열어 접속한 뒤 html을 긁어옴 1. chrome://version 을 검색해서 버전을 확인 2. chorme webdriver download를 입력해.. 2020. 8. 30.
[김플 스튜디오] 구글 로그인, 메일 보내기 자동화 (selenium, webdriver, actionchains) 실습 전 할 것 1. 내 크롬브라우저에 맞는 크롬드라이버를 다운 2. 실습하고자 하는 파이썬 파일에 해당 크롬 드라이버를 넣고 실습시작 => 실습(실행)파일과 동일한 루트에 넣으면 따로 루트 지정필요없이 => driver = webdriver.Chrome()만으로 실행가능 다음 코드를 입력 from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.action_chains import ActionChains # 쭉 연결할 수 있게함 import time driver = webdriver.Chrome() url = "https://google.com" driver.get.. 2020. 5. 6.
[김플 스튜디오] selenium : 크롬 검색 자동화 오류 from selenium import webdriver driver = webdriver.Chrome() 까지 입력하자 오류 해결 검색진행 내 크롬브라우저환경에 맞는 chromedriver다운 후 해당 주소 복사 정상 실행 크롬드라이버의 위치를 삽입 후 정상 실행 from selenium import webdriver driver = webdriver.Chrome(executable_path=r"C:\dev_python\Webdriver\chromedriver") url = 'https://google.com' driver.get(url) 코드 실행 (자동화 브라우저 작동) 구글 검색창의 클래스 확인 검색창 클래스 활용한 자동 검색어 입력 전체 코드에 하단 코드 추가 driver.find_eleme.. 2020. 5. 6.
반응형