python 分析Google音乐下载地址(二)
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif# coding=utf-8http://dashen2009.blog.51cto.com/images/editer/InBlock.gifimport urllib,re,sys,timehttp://dashen2009.blog.51cto.com/images/editer/InBlock.gif
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif
http://dashen2009.blog.51cto.com/images/editer/InBlock.gifurl='http://www.google.cn/music/topiclisting?q=top100_duet_love_songs&cat=song'
http://dashen2009.blog.51cto.com/images/editer/InBlock.gifprefix='http://www.google.cn/music/top100/musicdownload?id='
http://dashen2009.blog.51cto.com/images/editer/InBlock.gifdownname='songlist.txt'
http://dashen2009.blog.51cto.com/images/editer/InBlock.gifhtml=urllib.urlopen(url).read()
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif
http://dashen2009.blog.51cto.com/images/editer/InBlock.gifregx='下载.*window.*http.*\\\\x26resnum' #\x26resnum很奇怪,明明看到的是一个‘\’可是匹配不出来,好像是有两个‘\\’
http://dashen2009.blog.51cto.com/images/editer/InBlock.gifreobj=re.compile(regx)
http://dashen2009.blog.51cto.com/images/editer/InBlock.gifreg='http.*mp3' #文件下载地址
http://dashen2009.blog.51cto.com/images/editer/InBlock.gifrej=re.compile(reg)
http://dashen2009.blog.51cto.com/images/editer/InBlock.giflist=[]
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif
http://dashen2009.blog.51cto.com/images/editer/InBlock.giffor match in reobj.finditer(html):
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif list.append(match.group())
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif
http://dashen2009.blog.51cto.com/images/editer/InBlock.gifid=[]
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif
http://dashen2009.blog.51cto.com/images/editer/InBlock.giffor l in list:
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif id.append(prefix+urllib.unquote(l[-27:-10]))
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif
http://dashen2009.blog.51cto.com/images/editer/InBlock.gifdown=[]
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif
http://dashen2009.blog.51cto.com/images/editer/InBlock.giffor i in>http://dashen2009.blog.51cto.com/images/editer/InBlock.gif html=urllib.urlopen(i).read()
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif time.sleep(1)
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif for match in rej.finditer(html):
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif down.append(urllib.unquote(urllib.unquote(match.group())))
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif
http://dashen2009.blog.51cto.com/images/editer/InBlock.gifif len(down) >0:
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif file=open(downname,'w')
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif for d in down:
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif file.write(d+'\n')
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif file.close()
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif
http://dashen2009.blog.51cto.com/images/editer/InBlock.gifprint 'finish'
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif
http://dashen2009.blog.51cto.com/images/editer/InBlock.gif
页:
[1]