|
http://www.hackerschool.org/HS_Boards/zboard.php?AllArticle=true&no=6577 [복사]
import requests
from bs4 import BeautifulSoup
def spy(max_pages):
page = 1
while page < max_pages:
url = 'http://news.naver.com/main/main.nhn?mode=LSD&mid=shm&sid1=101' + str(page)
source_code = requests.get(url)
happy_text = source_code.text
soup = BeautifulSoup(happy_text, 'lxml')
for link in soup.select('dt > a#1063253_49479972'):
href = "http://news.naver.com/main/main.nhn?mode=LSD&mid=shm&sid1=101" +link.get('href')
title = link.string
print(href)
print(title)
page += 1
spy(2)
파이썬 크롤러 만들어 보았는데 안되네요 머가문제인지 아시는분 ㅠㅠ |
Hit : 4740 Date : 2017/04/29 11:55
|