以前在github上看到的,别人写的
来啊互粉啊~
源码一直留着喜欢阿,现在会requests了应该容易了吧,可我还没看
还有 垃圾软件毁我青春害我单身~
# -*- coding: utf-8 -*-
"""Automatically signing for NetEasy Music"""
import requests
import time
import json
from datetime import datetime as dt
MUSIC_U = "抓包结果"
hour = 5
__author__ = 'abrasumente'
REQUEST_URL =
TYPE_WEB = 1
TYPE_ANDROID = 0
def nesign(music_u, web=True, android=True):
"""签到
usage:
>>> from nesign import nesign
>>> result = nesign('MY MUSIC_U')
{'android': {'point': 3, 'code': 200}, 'web': {'point': 2, 'code': 200}}
>>> result = nesign('MY MUSIC_U') # 错误一般会有一个 msg 字段
{'android': {'code': -2, 'msg': '重复签到'}, 'web': {'code': -2, 'msg': '重复签到'}}
>>> result = nesign('一个非法的 MUSIC_U') # 当然也有特例
{'android': {'code': 301}, 'web': {'code': 301}}
:type music_u: str
:param music_u: 你的登陆 token,可以在 web 端下登录后在 域下的 cookies 找到
:param web: web 端两经验签到
:param android: android 端三点经验签到
:rtype: dict
"""
cookies = {'MUSIC_U': music_u}
headers = {'Referer':
result = {}
if not (web or android):
raise ValueError('至少指定一种签到类型')
if web:
url = REQUEST_URL.format(TYPE_WEB)
response = requests.post(url, cookies=cookies,
headers=headers)
result['web'] = response.json()
if android:
url = REQUEST_URL.format(TYPE_ANDROID)
response = requests.post(url, cookies=cookies,
headers=headers)
result['android'] = response.json()
return result
if __name__ == '__main__':
while 1:
result = nesign(MUSIC_U)
print json.dumps(result, ensure_ascii=False, indent=4)
print dt.now(), '='*20,
print '\nsleeping %s hours...' % hour
time.sleep(60*60*hour)