<p style="margin:0px 0px 10px;padding:0px;color:#404040;font-family:'Apple SD Gothic Neo', AppleGothic, Roboto, Gulim, Dotum, 'Noto Sans KR', sans-serif;">안녕하세요, 이미지 크롤링을 사용하던 도중 개선하고 싶은 부분이 있어 이렇게 질문 올립니다.</p><br style="color:#404040;font-family:'Apple SD Gothic Neo', AppleGothic, Roboto, Gulim, Dotum, 'Noto Sans KR', sans-serif;"><p style="margin:0px 0px 10px;padding:0px;color:#404040;font-family:'Apple SD Gothic Neo', AppleGothic, Roboto, Gulim, Dotum, 'Noto Sans KR', sans-serif;">이미지 크기와 관련된 문제인데요,</p> <p style="margin:0px 0px 10px;padding:0px;color:#404040;font-family:'Apple SD Gothic Neo', AppleGothic, Roboto, Gulim, Dotum, 'Noto Sans KR', sans-serif;"><br></p> <p style="margin:0px 0px 10px;padding:0px;color:#404040;font-family:'Apple SD Gothic Neo', AppleGothic, Roboto, Gulim, Dotum, 'Noto Sans KR', sans-serif;">한가지 예시를 위해서 사진을 첨부하겠습니다. 구글에 '구글' 키워드로 검색 한 후 이미지 탭에 들어간 화면입니다.</p> <p style="margin:0px 0px 10px;padding:0px;color:#404040;font-family:'Apple SD Gothic Neo', AppleGothic, Roboto, Gulim, Dotum, 'Noto Sans KR', sans-serif;"><br></p> <p style="margin:0px 0px 10px;padding:0px;color:#404040;font-family:'Apple SD Gothic Neo', AppleGothic, Roboto, Gulim, Dotum, 'Noto Sans KR', sans-serif;"></p> <div style="text-align:left;"><img src="http://thimg.todayhumor.co.kr/upfile/202005/1589467587095b71b395d045f0b59c9b35b4baa6b6__mn171753__w1440__h759__f148854__Ym202005.png" width="800" height="422" alt="제목 없음.png" class="chimg_photo" style="border:none;" filesize="148854"></div><br><p></p> <p style="margin:0px 0px 10px;padding:0px;color:#404040;font-family:'Apple SD Gothic Neo', AppleGothic, Roboto, Gulim, Dotum, 'Noto Sans KR', sans-serif;"><br></p> <p style="margin:0px 0px 10px;padding:0px;color:#333333;font-family:'Helvetica Neue', Helvetica, Arial, 'Apple SD Gothic Neo', 'Malgun Gothic', Dotdum;font-size:14px;">이미지 탭에서 저는 3번째 이미지를 클릭해서 오른쪽에 큰 이미지로 띄워놓았습니다.</p> <p style="margin:0px 0px 10px;padding:0px;color:#333333;font-family:'Helvetica Neue', Helvetica, Arial, 'Apple SD Gothic Neo', 'Malgun Gothic', Dotdum;font-size:14px;">좌측 3번째 이미지에 오른쪽클릭을 하여 사진 저장, 그리고 우측에 띄워놓은 큰 이미지를 우측으로 저장하면</p> <p style="margin:0px 0px 10px;padding:0px;color:#404040;font-family:'Apple SD Gothic Neo', AppleGothic, Roboto, Gulim, Dotum, 'Noto Sans KR', sans-serif;"><br></p> <p style="margin:0px 0px 10px;padding:0px;color:#333333;font-family:'Helvetica Neue', Helvetica, Arial, 'Apple SD Gothic Neo', 'Malgun Gothic', Dotdum;font-size:14px;">아래와 같은 크기 차이가 발생합니다.</p> <div><br style="font-family:'Apple SD Gothic Neo', '맑은 고딕', 'Malgun Gothic', '돋움', dotum, sans-serif;font-size:15px;"></div> <div> <div style="text-align:left;"><img src="http://thimg.todayhumor.co.kr/upfile/202005/158946761386142de928184116b011930081f08281__mn171753__w225__h225__f5675__Ym202005.png" width="225" height="225" alt="다운로드.png" style="border:none;" filesize="5675"></div><br></div> <div> <div style="text-align:left;"><img src="http://thimg.todayhumor.co.kr/upfile/202005/15894676245b14531c89a14ea5863a16aa43b9c273__mn171753__w1024__h1024__f27520__Ym202005.png" width="800" height="800" alt="Google_Lens_-_new_logo.png" class="chimg_photo" style="border:none;" filesize="27520"></div><br></div> <div><br></div> <div> <p style="margin:0px 0px 10px;padding:0px;color:#333333;font-family:'Helvetica Neue', Helvetica, Arial, 'Apple SD Gothic Neo', 'Malgun Gothic', Dotdum;font-size:14px;">여기서, 저는 아래와 같은 이미지 크기를 추출하고 싶은데,</p> <p style="margin:0px 0px 10px;padding:0px;color:#404040;font-family:'Apple SD Gothic Neo', AppleGothic, Roboto, Gulim, Dotum, 'Noto Sans KR', sans-serif;"><br></p> <p style="margin:0px 0px 10px;padding:0px;color:#333333;font-family:'Helvetica Neue', Helvetica, Arial, 'Apple SD Gothic Neo', 'Malgun Gothic', Dotdum;font-size:14px;">문제는 특정 한개의 이미지만 추출하는게 아닌 수십개 정도의 이미지를 추출하곤 한다는 점 입니다.</p> <p style="margin:0px 0px 10px;padding:0px;color:#404040;font-family:'Apple SD Gothic Neo', AppleGothic, Roboto, Gulim, Dotum, 'Noto Sans KR', sans-serif;"><br></p> <p style="margin:0px 0px 10px;padding:0px;color:#333333;font-family:'Helvetica Neue', Helvetica, Arial, 'Apple SD Gothic Neo', 'Malgun Gothic', Dotdum;font-size:14px;">(구글만이 아니라 네이버도 그렇습니다.)</p> <p style="margin:0px 0px 10px;padding:0px;color:#404040;font-family:'Apple SD Gothic Neo', AppleGothic, Roboto, Gulim, Dotum, 'Noto Sans KR', sans-serif;"><br></p> <p style="margin:0px 0px 10px;padding:0px;color:#333333;font-family:'Helvetica Neue', Helvetica, Arial, 'Apple SD Gothic Neo', 'Malgun Gothic', Dotdum;font-size:14px;">이를 위해서 코드상에서 제가 위에서 해준 동작처럼,</p> <p style="margin:0px 0px 10px;padding:0px;color:#404040;font-family:'Apple SD Gothic Neo', AppleGothic, Roboto, Gulim, Dotum, 'Noto Sans KR', sans-serif;"><br></p> <p style="margin:0px 0px 10px;padding:0px;color:#333333;font-family:'Helvetica Neue', Helvetica, Arial, 'Apple SD Gothic Neo', 'Malgun Gothic', Dotdum;font-size:14px;">1. 이미지를 클릭 -> 2.우측에 뜬 이미지의 태그를 따서 다운로드 -> 3. 다음 이미지 넘어가기 (키보드 우측화살표 동작을 주면 될 것 같습니다.) -> 4. 우측에 뜬 이미지 태그를 따서 다운로드</p> <p style="margin:0px 0px 10px;padding:0px;color:#404040;font-family:'Apple SD Gothic Neo', AppleGothic, Roboto, Gulim, Dotum, 'Noto Sans KR', sans-serif;"><br></p> <p style="margin:0px 0px 10px;padding:0px;color:#333333;font-family:'Helvetica Neue', Helvetica, Arial, 'Apple SD Gothic Neo', 'Malgun Gothic', Dotdum;font-size:14px;">이런 작업을 해주어야 할까요? 기존에는 이미지 탭에서 이미지 태그가 스크롤 한 만큼 주르륵 나열되었기 때문에, 그냥 반복문으로 태그를 얻어오는 방식이면 됐었습니다만.. </p> <p style="margin:0px 0px 10px;padding:0px;color:#404040;font-family:'Apple SD Gothic Neo', AppleGothic, Roboto, Gulim, Dotum, 'Noto Sans KR', sans-serif;"><br></p> <p style="margin:0px 0px 10px;padding:0px;color:#333333;font-family:'Helvetica Neue', Helvetica, Arial, 'Apple SD Gothic Neo', 'Malgun Gothic', Dotdum;font-size:14px;">다른 방법이나, 효율적인(?) 무언가가 있나 싶어 질문 올립니다.</p> <p style="margin:0px 0px 10px;padding:0px;color:#333333;font-family:'Helvetica Neue', Helvetica, Arial, 'Apple SD Gothic Neo', 'Malgun Gothic', Dotdum;font-size:14px;">혹시나 해서 제 코드중에서 크롤링하는 부분의 코드만 첨부하겠습니다.</p> <p style="margin:0px 0px 10px;padding:0px;color:#333333;font-family:'Helvetica Neue', Helvetica, Arial, 'Apple SD Gothic Neo', 'Malgun Gothic', Dotdum;font-size:14px;"><br></p><pre style="margin-top:0px;margin-bottom:10px;padding:9.5px;font-size:9.8pt;color:#a9b7c6;overflow:auto;font-family:'jetbrains mono';line-height:1.42857;background-color:#2b2b2b;border:1px solid rgb(204,204,204);">html = driver.page_source<br>soup = BeautifulSoup(html<span style="color:#cc7832;">, </span><span style="color:#6a8759;">'lxml'</span>)<br><br>img = soup.select(<span style="color:#6a8759;">'.rg_i.Q4LuWd.tx8vtf'</span>)<br><span style="color:#6897bb;"><br></span>imgurl = []<br><span style="color:#cc7832;">for </span>i <span style="color:#cc7832;">in </span>img:<br><span style="color:#cc7832;">try</span>:<br> imgurl.append(i.attrs[<span style="color:#6a8759;">"src"</span>])<br><span style="color:#cc7832;">except </span><span style="color:#8888c6;">KeyError</span>:<br> imgurl.append(i.attrs[<span style="color:#6a8759;">"data-src"</span>])</pre></div>
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.