2.setting.py
Setting.py: 需要设置item pipeline和请求头即可,
(1) 去掉item_pipeline的注释,其作用是指定数据入库的函数,即scrapy在执行数据存储的时候使用哪一个类对象实现存储。
ITEM_PIPELINES = { 'scrapy_music.pipelines.ScrapyMusicPipeline': 300, 'scrapy_music.pipelines.DownloadMusicPipeline': 300, }//将激活ScrapyMusicPipeline和.DownloadMusicPipeline'
(2)还要设置请求头,即DEFAULT_REQUESTS_HEADERS去掉注释
DEFAULT_REQUEST_HEADERS = { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'User-Agent':'Mozilla/5.0(Windows NT 6.3; WOW64; rv:41.0)Gecko/20100101 Firefox/41.0', 'Accept-Language': 'en', }
user-Agent参数:
https://blog.csdn.net/qq_42231156/article/details/86285274