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

인프런 커뮤니티 질문&답변

Inhoo Song님의 프로필 이미지
Inhoo Song

작성한 질문수

초간단 초스피드 데이터 수집 (파이썬 크롤링)

url 링크 찾아내서 크롤링

질문이요

작성

·

203

2

import requests
from bs4 import BeautifulSoup
req = requests.get(
'https://www.donga.com/news/Entertainment/List?p=1&prod=news&ymd=&m=')
soup = BeautifulSoup(req.text
, 'html.parser')

for i in soup.select("#contents > div.page > a") :

req2 = requests.get(
"http://www.donga.com/news/List/Enter/" + i['href'])
soup2 = BeautifulSoup(req2.text
, 'html.parser')

for i in soup2.find_all("span", class_="tit") :
print(i.text)


C:\Users\karma\PycharmProjects\pychamwebcrawling\venv\Scripts\python.exe "C:/Users/karma/PycharmProjects/pychamwebcrawling/01_web_crawling_naver_test/url 링크 찾아내서 크롤링.py" Process finished with exit code 0

머가 문제인건가요???


답변 4

0

개복치개발자님의 프로필 이미지
개복치개발자
지식공유자

파이팅입니다~

0

감사합니다.

기초가부족한 상태라

기초를 잘 다져서 따라해보겠습니다

0

개복치개발자님의 프로필 이미지
개복치개발자
지식공유자

코드를 약간 수정했습니다 여기서부터 한번 시작해보실래요?

0

개복치개발자님의 프로필 이미지
개복치개발자
지식공유자

import requests
from bs4 import BeautifulSoup
req = requests.get('https://www.donga.com/news/Entertainment/List?p=1&prod=news&ymd=&m=')
soup = BeautifulSoup(req.text, 'html.parser')

print(soup.select("#content > div.page > a"))

for i in soup.select("#content > div.page > a") :
print("http://www.donga.com/news/List/Enter/" + i['href'])

Inhoo Song님의 프로필 이미지
Inhoo Song

작성한 질문수

질문하기