프로그래밍

 3198, 1/160 회원가입  로그인  
   zero1
   파이썬 코드가 뭐가문제인지 ㅠㅠ

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



    
stdcdgu lxml도 import 해주셔야 합니다 2017/08/31