에러 발생
287
aris0610
작성한 질문수 1
0
이런 에러가 발생하네요. ㅜㅜ
AttributeError Traceback (most recent call last)
<ipython-input-8-7192c5c336e6> in <module>() ----> 1 imageDown('유재석')
<ipython-input-5-04e1644ec3a6> in imageDown(keyword) 8 driver.get(url) 9 ---> 10 body = driver.find_element_by_css_selector('body') 11 12 # 페이지 다운시켜서 더 많은 이미지가 나오게 한다
AttributeError: 'WebDriver' object has no attribute 'find_element_by_css_selector'
답변 1
0
저도 같은 문제 생겨서 구글링해보니까 요렇게 바꿔서 됐어요 ㅋㅋ
def imageDown(keyword):
url = f'https://www.google.com.br/search?q={keyword}&source=lnms&tbm=isch'
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome('chromedriver', chrome_options=chrome_options)
driver.get(url)
body = driver.find_element(By.CSS_SELECTOR, 'body')
# 페이지 다운시켜서 더 많은 이미지가 나오게 한다
for i in range(30):
body.send_keys(Keys.PAGE_DOWN)
time.sleep(0.5)#한번 드래그 후 sleep
imgs = driver.find_elements(By.CSS_SELECTOR, 'img.rg_i')
os.makedirs(keyword, exist_ok=True)
time.sleep(10)
for idx, img in enumerate(imgs):
# print(idx,img.get_attribute('src'))
imgUrl = img.get_attribute('src')
if imgUrl == None:
break
imgName = f'./{keyword}/{keyword+str(idx)}.jpg'
urllib.request.urlretrieve(imgUrl, imgName)
커서, 클로드, 피그마는 모두 유료버전을 사용해야하나요?
0
22
1
구글 서치콘솔 도메인 소유권 확인 실패
0
13
1
antigravity로 하던 작업 이제 visual code로 하면 되는 거죠?
0
28
1
다음 강의 얼른 올려주세요
0
23
2
일반 강의와 차이점?
1
25
1
중요하진 않지만 설명하신부분에서 안된부분..
0
23
0
안녕하세요, 강좌 5의 피그마 파일은 어디서 볼 수 있나요?
0
52
2
stopPropagation()에 대해서 질문 있습니다.
0
36
2
뉴스페이퍼 싱글템플릿 모바일 화면 디자인 질문
0
34
2
노션에 20.Contact가 없어요
0
43
2
검색엔진 차단 noindex
0
43
2
파트9 강의는 언제 오픈하시나요
0
47
2
ZIP 파일
0
45
2
26강 13F 강의 불일치 및 질문 요청
0
58
3
state 객체로 묶기
0
40
1
XAMPP에서 Apache, DB 재기동 시 접속안되는 문제
0
28
2
Breadth (등락 비율) 분석
0
28
1
26 .강의 프롬프트와 프롬프트파일(part3) 내용이 차이가 있어요.
0
33
2
6-6
0
33
1
Json 플러그인 사용시 variable collection 없음
0
47
2
배리어블 목록 없음
0
74
3
Token 등록 방법 문의
0
35
1
6-6 실습 문의
0
35
2
섹션5 노션링크 는 따로 없나요?
0
39
2





