Netease cloud music login python

NetEase Cloud web version login example script.js This algorithm is a bit long and will not be posted. If you need to privately chat, I will send it to youEnter image description

# -*- coding: utf-8 -*-
import re
import requests
import execjs
import hashlib
import sys
import json
import urllib2
reload(sys)
sys.setdefaultencoding("utf-8")


def postHttp(url,data):
    headers = {
               'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0 Iceweasel/38.3.0',
               'Content-Type': 'application/x-www-form-urlencoded'
    }
    print data
    request = urllib2.Request(url=url, headers=headers, data=data)
    response = urllib2.urlopen(request)
    json_p=json.loads(response.read())
    print '返回数据:{0}'.format(json_p)
    print '协议头:{0}'.format(response.headers)
    print '用户名:{0}'.format(json_p['profile']['nickname'])
def Md5(passd):
    m = hashlib.md5()
    m.update(passd)
    return m.hexdigest()
def UrlEn(text):
    return execjs.compile("var url=function(a){return encodeURIComponent(a);}").call('url',text)
def Login(user,passd):
    js = open('script.js').read()
    p=Md5(passd)
    obj=execjs.compile(js).call('asrsea',user,p).split("-")
    print postHttp("http://music.163.com/weapi/login/cellphone?csrf_token=",'params='+UrlEn(obj[0])+'&encSecKey='+obj[1])
#仅仅支持手机号登录-没有处理验证码部分
print Login("手机帐号","密码")

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325819229&siteId=291194637