강의

멘토링

커뮤니티

Inflearn Community Q&A

songmeraki1007's profile image
songmeraki1007

asked

Super-easy, super-fast data collection (Python crawling)

Find url links and crawl them

질문이요

Written on

·

236

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

머가 문제인건가요???


웹-크롤링python

Answer 4

0

bokchi님의 프로필 이미지
bokchi
Instructor

파이팅입니다~

0

감사합니다.

기초가부족한 상태라

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

0

bokchi님의 프로필 이미지
bokchi
Instructor

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

0

bokchi님의 프로필 이미지
bokchi
Instructor

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'])

songmeraki1007's profile image
songmeraki1007

asked

Ask a question