# hackernews_spider.py
import scrapy

class HackerNewsSpider(scrapy.Spider):
    name = "hackernews"
    start_urls = ["https://news.ycombinator.com"]

    def parse(self, response):
        # Get all stories
        for story in response.css("span.titleline"):
            # Extract story title
            yield {"title": story.css("a::text").get()}

        # Go to next page if available
        # if next_page := response.css('a.morelink::attr(href)').get():
        #     yield response.follow(next_page, self.parse)