There are a number of RFC documents that sometimes want to flip through without networking, and can only download a copy of the Local.
Look at the address list, which is probably the range:
Http://www.networksorcery.com/enp/rfc/rfc1000.txt
...
Http://www.networksorcery.com/enp/rfc/rfc6409.txt
Haha, very suitable for bulk download, the first thought is the thunderbolt ...
When available, I found that it only supports three-digit extensions (Thunder 7), and I want a four-digit number.
Depressed under the initiation of their own to do an idea!
This is a good thing to do with Python, the principle is simple, the code is very small, read first as fast.
The code is as follows:
Copy Code code as follows:
#! /usr/bin/python
'''
File:getRFC.py
Author:mike
E-mail:mike_zhang@live.com
'''
Import Urllib,os,shutil,time
def downloadhtmlpage (Url,tmpf = '):
i = url.rfind ('/')
FileName = url[i+1:]
If Tmpf:filename = Tmpf
Print URL, "->", FileName
Urllib.urlretrieve (Url,filename)
print ' downloaded ', fileName
Time.sleep (0.2)
Return FileName
# Http://www.networksorcery.com/enp/rfc/rfc1000.txt
# Http://www.networksorcery.com/enp/rfc/rfc6409.txt
if __name__ = = ' __main__ ':
addr = ' HTTP://WWW.NETWORKSORCERY.COM/ENP/RFC '
Dirpath = "RFC"
#startIndex = 1000
startIndex = Int (raw_input (' Start: '))
#endIndex = 6409
endindex = Int (raw_input (' End: '))
If StartIndex > Endindex:
print ' Input error! '
if False = = Os.path.exists (Dirpath):
Os.makedirs (Dirpath)
Filedownloadlist = []
LogFile = open ("Log.txt", "W")
For I in Range (startindex,endindex+1):
Try
T_url = '%s/rfc%d.txt '% (addr,i)
FileName = Downloadhtmlpage (T_url)
Oldname = './' +filename
NewName = './' +dirpath+ '/' +filename
if True = = Os.path.exists (oldname):
Shutil.move (Oldname,newname)
print ' moved ', Oldname, ' to ', newName
Except
Msglog = ' Get%s failed! '% (i)
Print Msglog
Logfile.write (msglog+ ' \ n ')
Continue
Logfile.close ()
In addition to the RFC documentation, this program can be slightly modified to do other things: such as bulk download MP3, E-books and so on.
Well, that's all, I hope to help you.