3
任何人都可以看到一個問題,此代碼,因爲它正在添加保持背部有一個錯誤,這是代碼和生病後的代碼下的錯誤...感謝先進的幫助...Python從URL錯誤下載?
import commands
import os
import pickle
def readDir():
directory = raw_input('In which folder would you like to save the files?? \n')
if(os.path.exists(directory)):
print 'Error!! Please give an other name '
directory = raw_input('In which folder would you like to save the file??\n')
os.mkdir(directory)
os.chdir(directory)
else:
os.mkdir(directory)
os.chdir(directory)
readDir()
url = raw_input('Which url are you aiming at ?\n')
tmp = open('tempo.txt','w');
tmp.writelines(url)
tmp.close()
tmp = open('tempo.txt','r');
link = tmp.read()
os.system(" curl " + link +"| egrep -o 'http:.*All\.ram' > final.txt ")
infile = open('final.txt', 'r')
outfile = open('tmp.txt', 'w')
for line in infile:
outfile = open('tmp.txt', 'w')
key = line
list = key.split("/")
dir = list[6]
outfile.writelines(key)
outfile.close()
open('tmp.txt','r')
os.system("cat tmp.txt | xargs -n1 -i curl {} > links")
os.system("wget -P %s -i links" %dir)
infile.close()
outfile.close()
os.remove(outfile.name)
os.remove('links')
os.remove(tmp.name)
錯誤:我只是用谷歌作爲例子。
Which url are you aiming at ?
google.com
'curl' is not recognized as an internal or external command, operable program or batch file.
Traceback (most recent call last):
File "C:\Users\User\Desktop\download.py", line 52, in <module>
infile = open('final.txt', 'r')
IOError: [Errno 2] No such file or directory: 'final.txt'
感謝在那裏,我可以抓住的網址,而不是使用curl任何其他方式? – Terrii
是的,使用urllib。 http://docs.python.org/2/library/urllib.html – PearsonArtPhoto
謝謝,但我不能解決它:/ – Terrii