在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 = ""
URL2 = "&b=+%CB%D1%CB%F7+&lg=0&k=&aid=&ty=1"
URL = URL1 + urllib2.quote(name) + URL2
#URL = "%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 = "" + i
print lrcURL
sock.close()
阅读(3294) | 评论(2) | 转发(0) |