本文整理匯總了Python中HelperFunctions.downloadToFile方法的典型用法代碼示例。如果您正苦於以下問題:Python HelperFunctions.downloadToFile方法的具體用法?Python HelperFunctions.downloadToFile怎麽用?Python HelperFunctions.downloadToFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類HelperFunctions
的用法示例。
在下文中一共展示了HelperFunctions.downloadToFile方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: range
# 需要導入模塊: import HelperFunctions [as 別名]
# 或者: from HelperFunctions import downloadToFile [as 別名]
for d in range(1, 32):
mon = "0" + str(m) if m < 10 else str(m)
day = "0" + str(d) if d < 10 else str(d)
try:
os.mkdir("Devel/" + mon)
except:
pass
try:
os.mkdir("Usr/" + mon)
except:
pass
fileName = mon + "/" + year + "-" + mon + "-" + day + ".txt"
devUrl = devRoot + "/" + year + "/" + year + "-" + fileName
usrUrl = usrRoot + "/" + year + "/" + year + "-" + fileName
print("Dnld Devel... " + fileName)
HF.downloadToFile(devUrl, "Devel/" + fileName)
print("Dnld User... " + "Usr/" + fileName)
HF.downloadToFile(usrUrl, "Usr/" + fileName)
print("=======================================")
# Phew!!
print("All Done!")
示例2: print
# 需要導入模塊: import HelperFunctions [as 別名]
# 或者: from HelperFunctions import downloadToFile [as 別名]
for artist in os.listdir("G:\\Music\\#More"):
if '#' not in artist:
if os.path.isdir("G:\\Music\\#More\\" + artist):
artistFolder = "G:\\Music\\#More\\" + artist
else:
continue
# The file where lastfm response will be saved
fileName = "Artists\\" + artist + " - Top " + limit + ".xml"
print("Downloading File... " + artist)
# Download to file
params = urllib.parse.urlencode({'method': 'artist.gettoptracks', 'artist': artist, 'api_key': api_key, 'limit': limit})
if (HelperFunctions.downloadToFile(root_url+params, fileName) == 0):
print("Skipping... " + artist)
print("=====================")
continue
# Build a parse tree
tree = ET.parse(fileName).find("toptracks")
# Output playlist file
playlist = artistFolder + "\\" + artist + " - Top " + limit + ".m3u"
op = open(playlist, "w")
print("Building Playlist... " + artist)
# Iter through the XML
for item in tree.findall("track"):