Home > other >  What is this error interface is there a problem? python
What is this error interface is there a problem? python

Time:01-26

# coding: utf-8
"'
@ the author: ZainCheung
@ LastEditors: ZainCheung
@ description: netease cloud music automatic daily clock in cloud function version
@ Date: 2020-06-25 14:28:48
@ LastEditTime: the 2020-09-01 18:20:00
"'
The from configparser import configparser
The from threading import Timer
The import requests
Import the random
The import hashlib
Import a datetime
The import time
The import json
The import of logging
The import math

The logger=logging. GetLogger ()
,40,70,130,200,400,1000,3000,8000,20000 grade=[10]
API='

The class Task (object) :

"'
The object constructor
"'
Def __init__ (self, uin, PWD, sckey, countrycode=86) :
The self. The uin=uin
Self. PWD=PWD
The self. The countrycode=countrycode
Self. Sckey=sckey

"'
Take the user's cookie to send data
Full url path url:
Of data to be sent in the post way postJson:
Returns the response
"'
Def the method getResponse (self, url, postJson) :
Response=requests. Post (data=https://bbs.csdn.net/topics/postJson url, headers={' the content-type: 'application/x - WWW - form - urlencoded'}, cookies=self. Cookies)
Return the response

"'
Login
"'
Def login (self) :
Data={https://bbs.csdn.net/topics/"uin" : the self. The uin, "PWD" : the self. The PWD, "countrycode" : the self. The countrycode, "r" : the random, random ()}
If the '@' in the self. Uin:
Url=API + '? Do=email '
The else:
Url=API + '? Do=login '
The response=requests. Post (url, data=https://bbs.csdn.net/topics/data, headers={' the content-type: 'application/x - WWW - form - urlencoded'})
Code=json. Loads (response. The text) [' code ']
The self. The name=json. The loads (the response. The text) [' profile '] [' nickname ']
The self. The uid=json. The loads (the response. The text) [' account '] [' id ']
If code==200:
The self. The error='
The else:
The self. The error='login failed, please check account
Self. Cookies=response. Cookies. Get_dict ()
The self. The log (' login successful ')

"'
Daily check in
"'
Def sign (self) :
Url=API + '? Do=sign '
The response=self. The method getResponse (url, {" r ": the random. The random ()})
Data=https://bbs.csdn.net/topics/json.loads (the response text)
If the data [' code ']==200:
The self. The log (' sign in successfully)
The else:
The self. The log (' repeat sign in)

"'
Daily clock in 300 songs
"'
Def daka (self) :
Url=API + '? Do=daka '
The response=self. The method getResponse (url, {" r ": the random. The random ()})
The self. The log (response. The text)

"'
Query the user details
"'
Def detail (self) :
Url=API + '? Do the detail of='
Data=https://bbs.csdn.net/topics/{uid, "uid" : the self. "r" : the random, random ()}
The response=self. The method getResponse (url, data)
Data=https://bbs.csdn.net/topics/json.loads (the response text)
Self. Level=data [' level ']
Self. ListenSongs=data [' listenSongs]
The self. The log (' success get the user details')

"'
Server push
"'
Def server (self) :
If self. Sckey==":
Return
Url='https://sc.ftqq.com/' + self. Sckey + 'send'
Self. DiyText () # construct send content
The response=requests. Get (url, params={" text ": the self. The title," desp ": the self. The content})
Data=https://bbs.csdn.net/topics/json.loads (the response text)
If the data [' errno]==0:
Self. The log (' user: '+ self. The name +' Server sauce push success ')
The else:
The self. The log (' user: '+ self. The name +' Server sauce push failed, please check whether sckey right ')

"'
The content of the custom to push WeChat
Title: the title of the message
Content: the content of the message and support the MarkDown format
"'
Def diyText (self) :
# today=datetime. Date. Today ()
# kaoyan_day=datetime. Date (2020,12,21) # 2021 one's deceased father grind the end of the party's
# date=(kaoyan_day - today). Days
For the count in grade:
If the self. The level & lt; 10:
If self. ListenSongs & lt; 20000:
If self. ListenSongs & lt; Count:
Self. Tip='also need songs' + STR (count - self. ListenSongs) +' first can upgrade '
Break
The else:
Self. Tip='you have heard enough 20000 songs, if the login number of days to 800 days to full level'
The else:
The self. The tip='congratulations you have full level! '
If the self. The error==":
State=(" - has now completed signed in \ n "
"- today's clock in total" + STR (self. Dakanum) + "\ n"
"- today broadcast" + STR (self. DakaSongs) + "song \ n
""- also need to punch" + STR (self. Day) + "day")
The self. The title=(" netease cloud clock today "+ STR (self. DakaSongs) +", has played "+ STR (self. ListenSongs) +" first ")
The else:
State=self. The error
The self. The title='netease cloud listening task problems! '
The self. The content=(
"-- -- -- -- -- - \ n"
"# # # # account information \ n"
"- the user name:" + STR (self. Name) + "\ n"
"- current level:" + STR (self) level) + "\ n level
""- cumulative play:" + STR (self. ListenSongs) + "\ n"
"- upgrade note:" + self. Tip + "\ n \ n"
"-- -- -- -- -- - \ n"
"# # # # task status \ n" + STR (state) + "\ n \ n"
"-- -- -- -- -- - \ n"
"Ring in log \ n # # # #" + self. DakaSongs_list + "\ n \ n")

"'
Print log
"'
Def log (self, text) :
Time_stamp=datetime. Datetime. Now ()
Print (time_stamp. Strftime (' % % % y. m. % d - H: % m: % S ') + "+ STR (text))
Self. Time=time_stamp. Strftime (' M H % : % : % S ')
Self. List. Append (" -/"+ self. Time +" "+ STR (text) +" \ n \ n ")

"'
Begin to execute
"'
Def start (self) :
Try:
Self. List=[]
Self. List. Append (" - initialization complete \ n \ n ")
The self. The login ()
Self. Sign ()
The self. The detail ()
Counter=self. ListenSongs
For I in range (1, 10) :
Self. Daka ()
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related