인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

jdo56404345's profile image
jdo56404345

asked

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

Get familiar by writing it yourself: Solving basic crawling practice problems (Updated)

섹션 4 마지막 강의 9분 30초

Written on

·

299

·

Edited

0

제가 짠 코드 인데 신박하게 짠 것 같아 기분이 좋아서 올렸습니다.

import requests

from bs4 import BeautifulSoup

res = requests.get('https://davelee-fun.github.io/index.html')

soup = BeautifulSoup(res.content,'html.parser')

mydata = soup.select('h4.card-text')

i=0

while i<4:

print(mydata[i].get_text().strip())

i+=1

 

분명 더 쉬운 방법이 있지만...

# 내 코드2

import requests

from bs4 import BeautifulSoup

res = requests.get('https://davelee-fun.github.io/index.html')

soup = BeautifulSoup(res.content,'html.parser')

featured = soup.select('.featured-posts')

for i in featured:

y = i.select('h4.card-text')

for x in y:

print(x.get_text().strip())

 

이렇게 두번째 코드는 강사님이랑 비슷하게 짜게 되었습니다.

python웹-크롤링

Answer 1

0

funcoding님의 프로필 이미지
funcoding
Instructor

안녕하세요. 답변 도우미입니다.

잘 작성하셨습니다. 크롤링과 파이썬, 그리고 프로그래밍에 대해 이해도가 서서히 높아지고 계시는 것 같습니다. ^^

감사합니다.

jdo56404345's profile image
jdo56404345

asked

Ask a question