1.创建scrapy项目 dos窗口输入: scrapy startproject images360 cd images360 2.编写item.py文件(相当于编写模板,需要爬取的数据在这里定义) import scrapy class Images360Item(scrapy.Item): # define the fields for your item here like: #图片ID image_id = scrapy.Field() #链接 url = scrapy.Field()
代码: import requests from lxml import etree text = requests.get("https://music.163.com/discover/toplist?id=3778678").text html = etree.HTML(text) id_list = html.xpath("//a[contains(@href,'/song?')]") for i in id_list: href = i.xpath(&qu