python 爬取某音乐平台所有歌单信息

# coding: utf-8
import requests
import os
from lxml import etree
import json
from spider_project.proxies import proxies
import random


class WangYiYunSpider:
    '''爬取所有歌单的信息'''

    def __init__(self):
        self.root_url = 'http://music.163.com'
        self.start_url = 'http://music.163.com/discover/playlist'
        self.classname_list = []  # 所有小类名
        self.class_url = 'http://music.163.com/discover/playlist/?cat={}'
        self.class_url_list = []  # 所有小类url
        self.playlist_urls = []  # 每一小类所有歌单的url
        self.headers = {
            'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
        self.playlist_info = []
        self.classname = ''
        self.proxies = proxies

    def parse_url(self, url=None):
        print(url)
        if url is None:
            resp = requests.get(self.start_url,
                                headers=self.headers,
                                proxies=random.choice(self.proxies)
                                )
        else:
            resp = requests.get(url, headers=self.headers)
        resp.encodin
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值