Home > other >  Small white, climb the netease cloud simplicity, error don't know what is wrong
Small white, climb the netease cloud simplicity, error don't know what is wrong

Time:10-25

The import requests
The import json
The from bs4 import BeautifulSoup

Def getHTMLText (url) :
Try:
Headers={
'the user-agent' : 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/SE 2. 537.36 X MetaSr 1.0 ',
'referer' : 'https://music.163.com/song? Id=513360721 '}
Params='ysy6utR5TDzRDDgUC859RSwFroydzmnUPrkxapdxPyXzH70nWQV/wADCQfdCgwxoQDiqLAfDMaPrDOxfFUuGatVIzvjL + u00wCUx6DtWfs8sZwNYR9/OouHrIpqKFXRgtRO0RRyDkIdA4h5qXHKqcXIVSTHpwnIanDa0aBZ + hjUGgC8FI1Q1onjseic9bzna'
Ef60ed8d8058e1d23586d9efd0cfc67213a656c9453db0eec39145f8a875dafaead2fac1ff422771758f0cae356a8ebf3651bbb5f26c575ad5320b373087c8928628fcf379a395b568d3e33dd4c02ea612b672a9aef0ce0f0ad3ecc971b14510b1cc675097940f24b1e7e884628d0d725f9245b77b95e6552da035e5f3ca53c encSecKey='6'
Data={
https://bbs.csdn.net/topics/'params' :' params',
'encSecKey' : 'encSecKey'}

R=requests. Post (url, headers=headers, data=https://bbs.csdn.net/topics/data)
R.r aise_for_status ()
R.e ncoding=of state Richard armitage pparent_encoding
Return r.t ext
Except:
Print (' wrong ')

Def getComments (HTML) :
Comments=json. Loads (HTML)
Hot_comments=comments [' hotComments]
With the open (' netease cloud comments. TXT ', 'w', encoding="utf-8") as f:
For each in hot_comments:
F.w rite (each [' user '] [] 'nickname' + ': \ n')
F.w rite (each [] 'content' + '\ n \ n')



Def the main () :
Url="https://music.163.com/weapi/v1/resource/comments/R_SO_4_513360721? Csrf_token='
HTML=getHTMLText (url)
GetComments (HTML)

If __name__=="__main__ ':
main()

CodePudding user response:

Data={
https://bbs.csdn.net/topics/'params' :' params',
'encSecKey' : 'encSecKey'}
Remove the quotes after the value
  • Related