虾米音乐的解码方法三种方法

import requests
# raw_url='9hFx%1795p_3%5a511t%i216753k15Edd7t2aF7376%e5E-c7cpFm145%93y3-257f%mi7%%58F%7%8b4f31.422E_a325%7e2A2n%FF5luD%E537b%8e223_.t15-E1f32.tF921mh5E%c9bd'
# num_loc=raw_url.find('h')
# print(num_loc)
# rows=int(raw_url[0:num_loc])
# print(rows)
# strlen = len(raw_url) - num_loc
# print(strlen)
# cols = int(strlen / rows)
# print(cols)
# right_rows = strlen % rows
# print(right_rows)
# new_s = raw_url[num_loc:]
# print(new_s)
# new_c=''
# strs=''
# if right_rows!=0:
# new_c = new_s + '*'
# n=1
# while 1:
# if len(new_c)%rows==0:
# break
# else:
# new_c = new_c[:-n*(cols + 1)] + '*' + new_c[-n*(cols + 1):]
# n+=1
# else:
# new_c=new_s
# for i in range(len(new_c)):
# print(i,('rows'),rows)
# x=i%(rows)
# print(x)
# y=int(i/(rows))
# print(y)
# p=x*(cols+1)+y
# print(p)
# strs+= new_c[int(p)]
# print(strs)
# aa=requests.utils.unquote(strs).replace('^', '0')
# print(aa)



# strs = '9hFx%265%7153y3-edc4t%i216E2456F%7%3f9bt2aF183F323a325df8cpFm6%%51478uD%E432%%mi65218%1.t15-489531.8EF7%54mh5E%78dEA2n%3245E3p_3%5bf16%8e2412E173k15E26f2.tF3%61_2%e5E-b19'
# h_index = strs.find('h')
# strs_num = len(strs[h_index:])//int(strs[:h_index])
# print(strs_num)
# strs_m = len(strs[h_index:])%int(strs[:h_index])
# print(strs_m)
# lists = []
# n = ''
# for i in range(strs_num+1):
# for j in range(int(strs[:h_index])):
# if j<strs_m or i<strs_num:
# lists.append((i,j))
# for i,j in lists:
# if j <= strs_m:
# index = j*(strs_num+1)+i
# else:
# index = strs_m * (strs_num+1) + (j - strs_m) * strs_num + i
# n+=strs[h_index:][index]
# print(requests.utils.unquote(n).replace('^', '0'))
#
#
#
def str2url(s):
num_loc = s.find('h')
rows = int(s[0:num_loc])
strlen = len(s) - num_loc
cols = int(strlen/rows)
right_rows = strlen % rows
new_s = s[num_loc:]
output = ''
for i in range(len(new_s)):
x = i % rows
y = int(i / rows)
p = 0
if x <= right_rows:
p = x * (cols+1) + y
else:
p = right_rows * (cols+1) + (x - right_rows) * cols + y
output += new_s[int(p)]
return requests.utils.unquote(output).replace('^', '0')
print(str2url('9hFx%265%7153y3-edc4t%i216E2456F%7%3f9bt2aF183F323a325df8cpFm6%%51478uD%E432%%mi65218%1.t15-489531.8EF7%54mh5E%78dEA2n%3245E3p_3%5bf16%8e2412E173k15E26f2.tF3%61_2%e5E-b19'))




import requests
# from lxml import etree
# header={
# 'referer': 'https://www.xiami.com/',
# 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36'
# }
# a=requests.get('https://www.xiami.com/search?key=张杰&pos=1',headers=header).text
# b=etree.HTML(a).xpath('//*[@class="song_name"]/a/text()')
# bb=etree.HTML(a).xpath('//*[@class="song_artist"]/a//text()')
# zhi=etree.HTML(a).xpath('//*[@class="chkbox"]/input/@value')
# print(len(zhi),zhi)
# c=''
# for i in bb:
# c+=i
# print(len(b),b)
# cc=c.split('\n\t\t\t\t\t\t\t\t\t\t\t\t')[1:]
# print(len(cc),cc)
# a='9hFx%265%7153y3-edc4t%i216E2456F%7%3f9bt2aF183F323a325df8cpFm6%%51478uD%E432%%mi65218%1.t15-489531.8EF7%54mh5E%78dEA2n%3245E3p_3%5bf16%8e2412E173k15E26f2.tF3%61_2%e5E-b19'
# b=a.find('h')
# print(b )
# ge=a[b:]
# print(ge)
# hang=a[:b]
# print(hang)
# shu=len(ge)//int(hang)+1
# print('每行的数+1;',shu)
# shao=shu*int(hang)-len(ge)
# print('少多少够整数:',shao)
# if shao!=0:
# nn=ge[-(shu-1):]+'*'
# nn2 = []
# if shao>1:
# for i in range(2,shao+1):
# nn1=ge[-i*(shu-1):-(i-1)*(shu-1)]+'*'
# nn2.insert(0,nn1)
# nn3=''
# for ii in nn2:
# nn3+=ii
# nnn=ge[:-shao*(shu-1)]+nn3+nn
# else:
# nnn=ge
# m=''
# for iii in range(shu):
# m+=nnn[iii::shu]
# aa=requests.utils.unquote(m).replace('*','').replace('^','0')
# print(aa)





猜你喜欢

转载自www.cnblogs.com/ygjn/p/9283929.html
今日推荐