Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8370029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:48:38+00:00 2026-06-09T13:48:38+00:00

I am trying to write a spider to crawl certain pages base on the

  • 0

I am trying to write a spider to crawl certain pages base on the data or info on the index page. And then store the result in a database.

For example, let say I would like to crawl stackoverflow.com/questions/tagged/scrapy
I would go through the index page, if the question is not in my database, then I would store the answer count in the database, then follow the link of the question and crawl that page.

if the question is already in the database, but the number of answer is greater than the one in the database: crawl that page again.

if the question is already in the database and the answer counter is the same: skip this question.

At the moment I could get all the links and answer counts(in this example)on the index page.
but I don’t know how to make the spider to follow the link to the question page base on the answer count.

Is there a way to do this with one spider instead of having two spiders, one spider is getting all the links on the index page, compares the data with the database, exports a json or csv file, and then passes it to another spider to crawl the question page?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:48:40+00:00Added an answer on June 9, 2026 at 1:48 pm

    Just use BaseSpider. That way you can make all the logic depend on the content you are scraping. I personally prefer BaseSpider since it gives you a lot more control over the scraping process.

    The spider should look something like this (this is more of a pseudo code):

    from scrapy.selector import HtmlXPathSelector
    from scrapy.spider import BaseSpider
    from scrapy.http import Request
    from myproject.items import MyItem
    
    class StackOverflow(BaseSpider):
        name = 'stackoverflow.com'
        allowed_domains = ['stackoverflow.com']
        start_urls = ['http://stackoverflow.com/questions']
    
        def parse(self, response):
            hxs = HtmlXPathSelector(response)
    
            for question in hxs.select('//question-xpath'):
                question_url = question.select('./question-url')
                answer_count = question.select('./answer-count-xpath')
                # you'll have to write the xpaths and db logic yourself
                if get_db_answer_count(question_url) != answer_count[0]:
                    yield Request(question_url, callback = self.parse_question)
    
        def parse_question(self, response):
            insert_question_and_answers_into_db
            pass
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to scrape pages using a Scrapy spider and then save those pages
I'm trying write a java program to send live microphone data over UDP, then
I am trying write a function that generates simulated data but if the simulated
I am trying to write a Spider Solitaire player as an exercise in learning
I've been trying to write this spider for weeks but without success. What is
I'm trying to write a function for featured slider. Basically, on one page I
I'm trying to write a java program that reads data from an image and
Trying to write a contact form script only my following page isnt processing... <?php
I am trying write a script where when a user clicks on a link,
I m trying write code that after reset set up rrpmax as 3000. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.