from scrapy_kafka.spiders import KafkaSpider
from example.items import DmozItem


class CustomKafkaSpider(KafkaSpider):
    name = "dmoz_kafka"
    allowed_domains = ["dmoz.org"]

    def parse(self, response):
        for sel in response.xpath('//ul/li'):
            item = DmozItem()
            item['title'] = sel.xpath('a/text()').extract()
            item['link'] = sel.xpath('a/@href').extract()
            item['desc'] = sel.xpath('text()').extract()
            yield item

from scrapy_kafka.spiders import ListeningKafkaSpider
from ..items import DmozItem


class CustomKafkaSpider(ListeningKafkaSpider):
    name = "dmoz_kafka"
    allowed_domains = ["dmoz.org"]

    def parse(self, response):
        for sel in response.xpath('//ul/li'):
            item = DmozItem()
            item['title'] = sel.xpath('a/text()').extract()
            item['link'] = sel.xpath('a/@href').extract()
            item['desc'] = sel.xpath('text()').extract()
            yield item

Use the correct Spider superclass in the example
Use the correct Spider superclass in the example

- from scrapy_kafka.spiders import KafkaSpider
+ from scrapy_kafka.spiders import ListeningKafkaSpider
- from example.items import DmozItem
+ from ..items import DmozItem
  
  
- class CustomKafkaSpider(KafkaSpider):
+ class CustomKafkaSpider(ListeningKafkaSpider):
      name = "dmoz_kafka"
      allowed_domains = ["dmoz.org"]
  
      def parse(self, response):
          for sel in response.xpath('//ul/li'):
              item = DmozItem()
              item['title'] = sel.xpath('a/text()').extract()
              item['link'] = sel.xpath('a/@href').extract()
              item['desc'] = sel.xpath('text()').extract()
              yield item
  
Use the correct Spider superclass in the example
## Code Before:
from scrapy_kafka.spiders import KafkaSpider
from example.items import DmozItem


class CustomKafkaSpider(KafkaSpider):
    name = "dmoz_kafka"
    allowed_domains = ["dmoz.org"]

    def parse(self, response):
        for sel in response.xpath('//ul/li'):
            item = DmozItem()
            item['title'] = sel.xpath('a/text()').extract()
            item['link'] = sel.xpath('a/@href').extract()
            item['desc'] = sel.xpath('text()').extract()
            yield item

## Instruction:
Use the correct Spider superclass in the example
## Code After:
from scrapy_kafka.spiders import ListeningKafkaSpider
from ..items import DmozItem


class CustomKafkaSpider(ListeningKafkaSpider):
    name = "dmoz_kafka"
    allowed_domains = ["dmoz.org"]

    def parse(self, response):
        for sel in response.xpath('//ul/li'):
            item = DmozItem()
            item['title'] = sel.xpath('a/text()').extract()
            item['link'] = sel.xpath('a/@href').extract()
            item['desc'] = sel.xpath('text()').extract()
            yield item
