I’d like to be able to read a file relative to the scrapy root directory, as described in
the documentation.
Is there a way of determining this path from inside the spider?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
I don’t know if scrapy is aware of where it is located on the filesystem, but in my
settings.pyi addPROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))then in spider you can say
Here I have assumed my project root is wherethe settings.py file is located. If you want to get the directory where
scrapy.cfgis you have to go up a directory