来自stackflow:
https://stackoverflow.com/questions/14075941/how-to-access-scrapy-settings-from-item-pipeline
读取settings.py
middlewares.py文件中
from scrapy.utils.project import get_project_settings
class YourSpider(BaseSpider):
def parse(self, response):
settings = get_project_settings()
print "Your USER_AGENT is:\n%s" % (settings.get('USER_AGENT'))
#USER_AGENT 在settings.py中定义好的