2017-04-04 8 views
0

getMonthEventsを入力しようとしています。しかし、どういうわけか、コールバックは決して実行されないようです。何か案は?感謝:)あなたがparseMonthであなたの要求を複製している一方でPython/Scrapy:コールバックのないyieldリクエスト

from scrapy.selector import Selector 
from scrapy.spiders import CrawlSpider, Rule 
from scrapy.linkextractors import LinkExtractor 
from scrapy.http import Request 
from scrapy.item import Item, Field 

class EventItems(Item): 
    Title = Field() 
    Link = Field() 
    Date = Field() 
    Time = Field() 
    Place = Field() 
    Description = Field() 
    Program=Field() 

class SpiderForHSMT(CrawlSpider): 
    name = 'HMTM' 
    start_urls = ['http://website.musikhochschule-muenchen.de/de/index.php?Itemid=602&id=565'] 
    rules =(Rule(LinkExtractor(restrict_xpaths=('//div[@id="VER_2013_DISPLAYSEARCHRESULTS"]/table[1]/tr[3]'), tags=('a',), attrs=('href',)), callback = 'parseMonth'),) 

    def parseMonth(self, response): 
     request = Request(response.url, callback = self.getMonthEvents) 
     yield request 

    def getMonthEvents(self, response): 
     print(response.url) 

答えて

2

要求が重複(see documentation)としてフィルタリングます。フィルタリングされないように、dont_filter=Trueをリクエストに追加します。

request = Request(response.url, dont_filter=True, callback = self.getMonthEvents) 
+0

ニース!それは動作します:)大きなおかげで! – Jason

関連する問題