강의

멘토링

커뮤니티

Inflearn Community Q&A

supremesang0427's profile image
supremesang0427

asked

[Renewal] Python Introduction and Web Crawling Basics Bootcamp [Python, Web, and Data Understanding Fundamentals] (Updated)

CSS 크롤링할 때 'img' 에러

Written on

·

197

0

CSS selector 로 크롤링을 하는데

'a', 'span', 'em'은 다 추출이 되는데

주식 사이트에서 'img'을 추출하려고 하니 에러가 발생합니다.

혹시 'img' 태그는 크롤링이 불가능한 건가요??

웹-크롤링python

Answer 2

1

funcoding님의 프로필 이미지
funcoding
Instructor

안녕하세요. 어떤 에러가 발생하는지 잘 모르겠는데요. 가볍게 다음과 같이 작성해보시면, 해당 주소를 추출하실 수 있으실 꺼예요.

감사합니다.

img_names = soup.find_all('img')

for img in img_names:

    ## img가 src 안에 있기 때문에 get_text가 아닌 src를 가져온다

    print(img['src'])

0

MireeneSang님의 프로필 이미지
MireeneSang
Questioner

항상 감사합니다!!!! 

supremesang0427's profile image
supremesang0427

asked

Ask a question