python - Scrapy - Load a yaml file with a relative path inside the spider -
 I am trying to implement my                       The relative path for code> has been posted on   on   and the     relative path is relative to the current working directory (the directory that started with your script). If you want to load a file from a path relative to the current script location, then you can try the following:   scrapy crawlers , but the problem is that my Pass  yaml file  is that I am trying to load from inside the  , it works when the spider is loaded from the shell:  scrapy crawl & lt; spider-name & gt; . But when the spider is deployed under  scrapyd , the path of the yaml file should be  complete .   scrapyd :   
 scrapyd-deploy default -p & Lt; project-name & gt; Curl http://127.0.0.1:6800/schedule.json -d project = & lt; Project-name & gt; -D spider = & lt; Spider-name & gt;    yaml  file is loaded as:   
 open ('../categories.yaml', 'r') F: Pass     
 root_dir = os.path.abspath (os.path.dirname (__ file__) ) yaml_pass = OS path.join (root_dir, '../categories/categories.yaml') with open (yaml_path, 'r') f: pass    
 
Comments
Post a Comment