There are a lot of RFC documents, and sometimes you want to flip through without the Internet, you can only download one copy locally.
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 thunderbolt ...
When available, it only supports three-digit expansion (with Thunderbolt 7), and I want exactly four digits ...
Depressed under the initiation of their own to do an idea!
This thing is very suitable for python, the principle is very simple, the code is very small, first read as fast.
The code is as follows:
Copy the 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, this program can do other things with a little modification: such as bulk download MP3, ebooks, etc.
All right, that's it, I hope it helps you.