from urllib2 import urlopen #method 1 def getDownUrl(id): #get location #xml location = urlopen("http://www.xiami.com/widget/xml-single/sid/"+repr(id)).read() begin = location.index("")+19 end = location.index("")-3 location = location[begin:end] #ready to decode List = [] result = "" col = int(location[0]) location = location[1:] pattLen = len(location) / col mod = len(location) % col #enjoy my terrible indices for i in range(0,col): List.append(location[:pattLen]) if mod != 0: List[i] += location[pattLen] mod -=1 location = location[len(List[i]):] i+=1 #rebuild the download link for i in range(0,pattLen+1): for j in range(0,col): if i