Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set CrawlSpider settings from Job() #10

Open
Matthijz98 opened this issue Dec 20, 2020 · 0 comments
Open

set CrawlSpider settings from Job() #10

Matthijz98 opened this issue Dec 20, 2020 · 0 comments

Comments

@Matthijz98
Copy link

Hi,

I am trying to use a CrawlSpider with Celery. The settings for the CrawlSpider are stored in the database. But what i try i can not get the settings passed to the CrawlSpider class.

My spider

class FindProductSpider(CrawlSpider):
    name = 'FindProductSpider'
    allowed_domains = ['']
    start_urls = ['']
    webshopid = ''
    rule = ''

    rules = [Rule(LinkExtractor(allow=rule), callback='parse_item', follow=True)]

    def parse_item(self, response):
        p = Product(url=response.url, from_webshop_id=self.webshopid)
        p.save()

and my celery task:

@shared_task()
def getproducts():
    webshops = Webshop.objects.all()

    for webshop in webshops:
        job = Job(FindProductSpider,
                  start_urls=[webshop.spider_start_url],
                  allowed_domain=[webshop.spider_allowed_domain],
                  rule=webshop.spider_allow_regex,
                  webshopid=webshop.id
                  )
        processor = Processor(settings=settings)
        data = processor.run([job])

But when i print the settings they keep being empty.
Some help would be super nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant