Access django models inside of Scrapy

后端 未结 8 2241
执笔经年
执笔经年 2020-11-28 19:11

Is it possible to access my django models inside of a Scrapy pipeline, so that I can save my scraped data straight to my model?

I\'ve seen this, but I don\'t really

8条回答
  •  -上瘾入骨i
    2020-11-28 19:52

    setup-environ is deprecated. You may need to do the following in scrapy's settings file for newer versions of django 1.4+

    def setup_django_env():
        import sys, os, django
    
        sys.path.append('/path/to/django/myapp')
        os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'
    
    django.setup()
    

提交回复
热议问题