获得中搜mp3的歌词URL
时间:2008-06-13 来源:CUDev
在linux和windows下面,处理输入有些问题,改天再解决 :-)
#!/usr/bin/env python
# -*- fileencoding:gbk -*-
import urllib2
import re
import sys
name = "菊花台"
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
URL1 = "http://mp3.zhongsou.com/m?w="
URL2 = "&b=+%CB%D1%CB%F7+&lg=0&k=&aid=&ty=1"
URL = URL1 + urllib2.quote(name) + URL2
#URL = "http://mp3.zhongsou.com/m?w=%C7%E0%BB%A8%B4%C9&b=+%CB%D1%CB%F7+&lg=0&k=&aid=&ty=1"
sock = opener.open(URL)
htmlsource = sock.read()
lrcpattern = re.compile(r'ty=9.+?w=(.+?) target=_blank>')
list = re.findall(lrcpattern,htmlsource)
list = dict.fromkeys(list).keys()
for i in list:
print i
lrcURL = "http://mp3.zhongsou.com/ld?ty=12&w=" + i
print lrcURL
sock.close()
#!/usr/bin/env python
# -*- fileencoding:gbk -*-
import urllib2
import re
import sys
name = "菊花台"
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
URL1 = "http://mp3.zhongsou.com/m?w="
URL2 = "&b=+%CB%D1%CB%F7+&lg=0&k=&aid=&ty=1"
URL = URL1 + urllib2.quote(name) + URL2
#URL = "http://mp3.zhongsou.com/m?w=%C7%E0%BB%A8%B4%C9&b=+%CB%D1%CB%F7+&lg=0&k=&aid=&ty=1"
sock = opener.open(URL)
htmlsource = sock.read()
lrcpattern = re.compile(r'ty=9.+?w=(.+?) target=_blank>')
list = re.findall(lrcpattern,htmlsource)
list = dict.fromkeys(list).keys()
for i in list:
print i
lrcURL = "http://mp3.zhongsou.com/ld?ty=12&w=" + i
print lrcURL
sock.close()
相关阅读 更多 +