本文整理汇总了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"):