본문 바로가기
Python

[레드나이츠] 게시판 글 크롤링

by 퍼포먼스마케팅코더 2017. 1. 12.
반응형

import urllib.request                    

from bs4 import BeautifulSoup


plaync_URL = 'http://rk.plaync.com/board/free/view?articleId='

plaync_URL_behind = '&viewMode=list'


result1 = []


for num in range(145472, 145798) :

    num +=1

    result1.append(num)


for page in result1 :

      url = plaync_URL+str(page)+plaync_URL_behind

      f = urllib.request.urlopen(url)

      html = f.read()

      bs = BeautifulSoup(html, 'html.parser')

      post_title = bs.find_all("meta", property="og:title")

      post_description = bs.find("meta", name_="twitter:description")

      print(post_title)

      print(post_description)



#수정: 수정해야될 부분은 http 접속시 error 500 뜰시 해결방법 모색해야됨.



반응형

댓글