본문 바로가기

Crawling15

Selenium 라이브러리 오류 모음 NoSuchElementException = 해당 엘리먼트가 없습니다 ElementNotSelectableException = 엘리먼트를 선택할 수 없습니다 ElementNotVisibleException = 엘리먼트가 보이지 않습니다 InvalidArgumentException = 인수가 잘못됐습니다 InvalidSelectorException = 선택자가 잘못됐습니다 NoSuhAttributeException = 엘리먼트에 해당 속성을 찾을수 없습니다 TimeoutException = 시간초과 WebDriverException = 웹드라이버 이상 에러 2022. 7. 19.
포켓몬 데이터 실습( os 라이브러리 : 파일, 폴더생성 / urlretrieve 라이브러리 : 이미지저장 / 파이썬 경로 입력 / isdir : 경로확인 / mkdir : 폴더생성 / 속성 src 추출 / 자동스크롤 ) import os from urllib.request import urlretrieve if not os.path.isdir("경로/폴더이름") : os.mkdir("경로/폴더이름") print("폴더생성 완료") else : print("폴더가 이미 존재합니다") img=soup.select('데이터위치') img[0].text --->> x img[0]['src'] -->> o ?.text 는 열린 태그와 닫는 태그 사이에 있는 컨텐츠를 가져옴 img_list = [] for i in img : img_list.append(i['src']) from selenium.webdriver.common.keys import Keys body=driver.find_element(By.CSS_SELECTOR, .. 2022. 7. 7.
지마켓 상품정보 가져오기 ( driver.back() ) 2022. 7. 7.
replace()와 strip를 섞어서 Crawling한 값 txt파일로 가져오기 all = driver.find_elements(By.CLASS_NAME,'concurrent_schedule__1Na5l') data= driver.find-elements(By.방식, 가져올 값) -->> 셀레니움 값 list=[] for i in data: j=i.text k=j.replace('원본', '뭘로 바꿀지').strip() list.append(k) strip() 양쪽 공백제거 rstrip() 오른쪽 공백제거 lstrip() 왼쪽 공백제거 replace('원본' , '바꿀값')에 [ ] 리스트를 이용하면 여러 갑을 한번에 바꿀수있다 2022. 7. 6.