这里爬取得是网易云音乐的歌单,大约5w。每个歌单可以继续爬取对应的歌曲(暂未实现)
from selenium import webdriver
import time
class WY:
def __init__(self):
self.url = "https://music.163.com/#/discover/playlist/"
self.driver = webdriver.Chrome()
def all_url_1(self):
'''
定义各个大分类的名称和url
'''
self.driver.get(self.url)
self.driver.switch_to_frame("contentFrame")
# self.driver.find_element_by_xpath("./html/body/div[@class='g-bd']/div[@class='g-wrap p-pl f-pr']/div/h3/a").click()
# time.sleep(1)
reqs = self.driver.find_elements_by_xpath("./html/body/div[@class='g-bd']/div[@class='g-wrap p-pl f-pr']/div[@class='n-sltlyr d-flag ']/div[@class='bd']/dl/dd/a")
list_1 = []
for req in reqs:
dic