日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python爬取网易云音乐问题陈述_python 网易云音乐 评论爬取问题

發(fā)布時(shí)間:2023/12/4 python 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python爬取网易云音乐问题陈述_python 网易云音乐 评论爬取问题 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

除了使用phantomjs,selenium之外,怎么爬取多頁評論,這兩個(gè)都太慢了。例如http://music.163.com/#/song?i... 的 評論。

webapi都是http://music.163.com/weapi/v1...,

每頁20個(gè)評論,怎么獲取下一頁的評論,param是加密的,post都不知道post什么數(shù)據(jù)

在網(wǎng)上有一種方式只能獲取

def aes_encrypt(self, text, secKey):

pad = 16 - len(text) % 16

text = text + pad * chr(pad)

encryptor = AES.new(secKey, 2, '0102030405060708')

ciphertext = encryptor.encrypt(text)

ciphertext = base64.b64encode(ciphertext)

return ciphertext

def rsa_encrypt(self, text, pubKey, modulus):

text = text[::-1]

rs = int(text.encode('hex'), 16) ** int(pubKey, 16) % int(modulus, 16)

return format(rs, 'x').zfill(256)

def create_secret_key(self, size):

return (''.join(map(lambda xx: (hex(ord(xx))[2:]), os.urandom(size))))[0:16]

def encrypt(self, url):

song_id = url[url.find('=') + 1:]

print song_id

url = 'http://music.163.com/weapi/v1/resource/comments/R_SO_4_' + str(song_id) + '/?csrf_token='

headers = {'Cookie': 'appver=1.5.0.75771;', 'Referer': 'http://music.163.com/song?id=27901109'}

text = {'username': '', 'password': '', 'rememberLogin': 'true', 'page': "2"}

modulus = '00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7'

nonce = '0CoJUm6Qyw8W8jud'

pub_key = '010001'

text = json.dumps(text)

sec_key = self.create_secret_key(16)

enc_Text = self.aes_encrypt(self.aes_encrypt(text, nonce), sec_key)

enc_sec_key = self.rsa_encrypt(sec_key, pub_key, modulus)

data = {'params': enc_Text, 'encSecKey': enc_sec_key}

req = requests.post(url, headers=headers, data=data)

data = req.json()

這種只能獲取前10條評論,后面的評論怎么獲取,急求大神指導(dǎo)啊

總結(jié)

以上是生活随笔為你收集整理的python爬取网易云音乐问题陈述_python 网易云音乐 评论爬取问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。