网易云音乐 post 请求闪退的原因有哪些?

2017-02-21 15:36:52 +08:00
 onsala

使用 requests 模拟网易云音乐的登录,运行下面这段代码,代码会立即闪退,感觉似乎根本没有做 post 请求,请问原因可能是什么,程序退出的速度太快了。

import requests


def login(username, password):
    session = requests.Session()
    url = 'https://music.163.com/weapi/login/'
    headers = {
        'Cookie': 'appver=1.5.2', 'Referer': 'http://music.163.com/', 
        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36'
    }

    text = {
        'username': username,
        'password': password,
        'rememberLogin': 'true'
    }
    data = encrypted_request(text)
    try:
        r = session.post(url, data=text, headers=headers)
        print r.text
    except requests.exceptions.RequestException as e:
        print e

# 邮箱登录
login('xxx@163.com', 'password')

encrpted_requests 的地址 https://gist.github.com/ormsf/130d72fe0c81cbf48e4c357dfe94a4c8

2141 次点击
所在节点    Python
2 条回复
holyzhou
2017-02-21 16:26:49 +08:00
没跑 , 但是你 post 的 data 还是用的没加密的 text 字典 这个有问题吧
onsala
2017-02-21 16:42:50 +08:00
@holyzhou 找了一个上午,多谢:P 。只是返回的状态码是 502 ,我重新试下。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/342075

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX