안녕 Python 뉴비야

Scrapy를 써서 디씨 페이지 하나에서 댓글만을 긁어오는 스크래퍼를 만들어보고 싶은데, 왜 안돼는지 모르겠당..

컴갤 첫번째 페이지를 열어서, 거기에서 크롬 검사로 나오는 XPATH 를 이용해서 댓글들에 접근하는건 했는데(크롬에 xpath helper로 댓글들만 주루룩 나오는건 봤어)

실제로 굴려보면 아무것도 못찾네.. ㅠㅠ

디씨갤은 원래 이게 안되도록 막혀있는건가?


spiders.py 내용 :


# -*- coding: utf-8 -*-
# 주의!!!
# 과도한 크롤링은 서버에 부하를 줄 수 있습니다. 적절한 딜레이를 통해 서버에 부담을 줄이셔야 함을 알립니다.

import scrapy
from DCreply.items import DCreplyItem


class DCreply_spider(scrapy.Spider):
name = "DCreply" # spider 이름
print 'DCreplyCalled'

def start_requestes(self):
#allowed_domains = ["gall.dcinsidie.com"]
#start_urls = ['http://gall.dcinside.com/board/view/?id=programming&no=1']

# for i in range(1,2,1):
yield scrapy.Request("http://gall.dcinside.com/board/view/?id=programming&no=1", self.parse_DCgal1)

def parse_DCgal1(self, response):
print 'PARSE CALLED'
# 글 하나의 댓글 리스트
for sel in response.xpath('//table/tr/td[@class="reply"]'):
item=DCreplyItem()
item['gallery'] = 'programming1' #댓글의 소속 게시판
item['text']=sel # 댓글의 text 개별 출력력

yield item