i'm still learning scrapy and i am trying to use scrapy with scrapyd inside a Django Project.
But i am noticing that the spider just wont enter the def(parse)
import scrapy
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule
class NewsSpider(CrawlSpider):
print("Start SPIDER")
name = 'detik'
allowed_domains = ['news.detik.com']
start_urls = ['https://news.detik.com/indeks/all/?date=02/28/2018']
def parse(self, response):
print("SEARCH LINK")
urls = response.xpath("//article/div/a/@href").extract()
for url in urls:
url = response.urljoin(url)
yield scrapy.Request(url=url, callback=self.parse_detail)
def parse_detail(self,response):
print("SCRAPEEE")
x = {}
x['breadcrumbs'] = response.xpath("//div[@class='breadcrumb']/a/text()").extract()
x['tanggal'] = response.xpath("//div[@class='date']/text()").extract_first()
x['penulis'] = response.xpath("//div[@class='author']/text()").extract_first()
x['judul'] = response.xpath("//h1/text()").extract_first()
x['berita'] = response.xpath("normalize-space(//div[@class='detail_text'])").extract_first()
x['tag'] = response.xpath("//div[@class='detail_tag']/a/text()").extract()
x['url'] = response.request.url
return x
The print("Start Spider") is in the log but the print("Search Link") is not.
i also have this kind of error
[Launcher,3804/stderr] Unhandled error in Deferred:
Please help. PS : When i run it outside the Django it work just fine
Thank you