博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
xiami_downloader辅助脚本
阅读量:6666 次
发布时间:2019-06-25

本文共 3486 字,大约阅读时间需要 11 分钟。

xiami_downloader 本体见 https://github.com/latyas/xiami-downloader

获取某歌手的所有专辑

# -*- coding: utf-8 -*-"""Created on Tue Nov 12 04:25:17 2013@author: latyas"""import requestsfrom bs4 import BeautifulSoupimport mathimport reimport sysurl = 'http://www.xiami.com/artist/album/id/%s/d//p/pub/page/%s'key_id = sys.argv[1]s = requests.session()lists = []header = {
'user-agent':'Mozilla/5.0'}ret = s.get(url % (key_id,'1'),headers=header)bs = BeautifulSoup(ret.text)foo = bs.find('p',attrs={
'class':'counts'})amount = int(re.findall('[0-9]+',foo.text)[0])pages = int(math.ceil(amount/9.0))for n in range(1,pages+1): ret = s.get(url % (key_id,str(n)),headers=header) bs = BeautifulSoup(ret.text) bar = bs.findAll('p',attrs={
'class':'name'}) for i in bar[:len(bar)/2]: barbar = i.find('a') lists.append(barbar.get('href').replace('/album/',''))for i in lists: print 'python xiami2.py --type=album --320k --remove %s' % i

instruction:

如:

python get_artist_albums.py 93341

输出:

python xiami2.py --type=album --320k --remove 1675369573

python xiami2.py --type=album --320k --remove 175768473
python xiami2.py --type=album --320k --remove 1862708947
python xiami2.py --type=album --320k --remove 557319
python xiami2.py --type=album --320k --remove 533626
python xiami2.py --type=album --320k --remove 548355
python xiami2.py --type=album --320k --remove 490416
python xiami2.py --type=album --320k --remove 501976
python xiami2.py --type=album --320k --remove 451818
python xiami2.py --type=album --320k --remove 545283

 

精选集相关搜索

# -*- coding: utf-8 -*-"""Created on Tue Nov 12 04:25:17 2013@author: latyas"""import requestsfrom bs4 import BeautifulSoupimport mathimport syskeyword = sys.argv[1]url ='http://www.xiami.com/collect/search/orderstatus/play_count/key/%s/page/' % keywords = requests.session()lists = []header = {
'user-agent':'Mozilla/5.0'}ret = s.get(url,headers=header)bs = BeautifulSoup(ret.text)foo = bs.find('div',attrs={
'class':'collectSort'})amount = int(foo.find('i').contents[0])pages = int(math.ceil(amount/30.0))for n in range(1,pages+1): ret = s.get(url+str(n),headers=header) bs = BeautifulSoup(ret.text) foofoo = bs.findAll('div',attrs={
'class':'block_cover'}) for i in foofoo: foobar = i.findAll('a') lists.append(foobar[0].get('href').replace('/song/showcollect/id/',''))for i in lists: print 'python xiami2.py --type=songlist --320k --onefolder --remove %s' % i print 'total:',len(lists)

INSTRUCTION:

python songlist.py "C81"

 

专辑名相关搜索

# -*- coding: utf-8 -*-"""Created on Tue Nov 12 04:25:17 2013@author: latyas"""import requestsfrom bs4 import BeautifulSoupimport mathimport syskeyword = sys.argv[1]url ='http://www.xiami.com/search/album/page/%s?key=%s&is_pub=y's = requests.session()lists = []header = {
'user-agent':'Mozilla/5.0'}ret = s.get(url % ('1',keyword),headers=header)bs = BeautifulSoup(ret.text)foo = bs.find('p',attrs={
'class':'seek_counts ok'})amount = int(foo.find('b').contents[0])pages = int(math.ceil(amount/12.0))for n in range(1,pages+1): ret = s.get(url % (str(n),keyword),headers=header) bs = BeautifulSoup(ret.text) bar = bs.findAll('p',attrs={
'class':'name'}) for i in bar: barbar = i.find('a') lists.append(barbar.get('href').replace('/album/',''))for i in lists: print 'python xiami2.py --type=album --remove --320k %s' % i

instruction:

python album_name.py "Little Buster!"

 

 

转载于:https://www.cnblogs.com/latyas/p/3450617.html

你可能感兴趣的文章
20165201 测试ch02
查看>>
精通javascript+jQuery(视频笔记)第二讲到第六讲
查看>>
poj1011
查看>>
div+css固定于浏览器
查看>>
[GCJ2017R2]Fresh Chocolate
查看>>
小B的询问
查看>>
陶哲轩实分析 习题 13.4.6
查看>>
我还算是个前端工程师吗?
查看>>
总结一
查看>>
二级小知识
查看>>
javascript中replace( )方法的使用——有博主已经讲过了,但里面有一小丢丢知识错误,挺重要的部分,我就重提下,以免初学者弄错...
查看>>
按字节提取整形数值(按位与运算符“&”、右移位运算符“>>”)
查看>>
《游戏引擎架构》笔记十三
查看>>
消除transition闪屏
查看>>
解Bug之路-记一次中间件导致的慢SQL排查过程
查看>>
WebWork(在主线程创建子进程)
查看>>
mongoDB与mongoose
查看>>
Mysql 常用语句
查看>>
Chisel3 - bind - Wire, Reg, MemPort
查看>>
官方Tomcat 7.0.81 漏洞整改记录
查看>>