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

本文共 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

你可能感兴趣的文章
ext的window如何隐藏水平滚动条
查看>>
71.8. Run level shell script to start Oracle 10g services on RedHat Enterprise Linux (RHAS 4)
查看>>
SAP QM Transfer of Inspection Stock
查看>>
全新视觉| 数治省市:SAP大数据构想一切可能
查看>>
ORACLE expdp备份与ORA-31693、ORA-02354、ORA-02149
查看>>
DBMS_STATS.GATHER_TABLE_STATS
查看>>
Java-单机版的书店管理系统(练习设计模块和思想_系列 五 )
查看>>
嵌入式 详解udev
查看>>
《C程序员:从校园到职场》出版预告(2):从“百花齐放”到“一枝独秀”
查看>>
Network Monitor 查询命令和MySQL命令
查看>>
好“戏”刚刚开幕 云计算逐步被认可
查看>>
云安全:这也是需要花大钱去建设的部分
查看>>
以全局产业观领航智慧城市建设
查看>>
5G网络不止能1秒下一部电影,它还能够…
查看>>
中国电信集采终端6700万部 金额达1070亿元
查看>>
2016年的十个数据中心故事
查看>>
《Java并发编程的艺术》一一3.3 顺序一致性
查看>>
《CCNP SWITCH 300-115认证考试指南》——导读
查看>>
《设计之外——比修图更重要的111件事》—第1部分3 虚心学习
查看>>
Solaris Studio 12.4 Beta update 7/2014
查看>>