查看文章
 
下载 起点中文的txt文章.
2007-11-27 11:45

<$$
Server.ScriptTimeOut=99999
for x=1 to 2500000
Set xPost = CreateObject("Microsoft.XMLHTTP")
xPost.Open "GET","http://download.cmfu.com/pda/"&x&".txt",False
xPost.Send()
Set sGet = CreateObject("ADODB.Stream")
sGet.Mode = 3
sGet.Type = 1
sGet.Open()
sGet.Write(xPost.responseBody)
sGet.SaveToFile Server.MapPath(""&x&".txt"),2
set sGet = nothing
set sPOST = nothing
next
$$>

------- 将要增加的功能! 1.将按照下载的txt的第一行中的关键词做为文本名. 2.将下载的txt文本中的某些词替换掉.

由于本人比较喜欢长一点的书。。所以。。。要修改一下。。。只下载大于500k的书吧。。

【code】

<%
Function ShowFileSize(filespec)
    file = Server.MapPath(filespec)
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(file) Then
    Set f = fso.GetFile(file)
intSizeB = f.Size
    intSizeK = Int((intSizeB/1024) + .5)
    If intSizeK = 0 Then intSizeK = 1
     ShowFileSize = intSizeK
Else
ShowFileSize = "File Doesn't Exist"
End If
Set fso = Nothing
End Function

Function deletefile(filespec)
    file = Server.MapPath(filespec)
Set fso = CreateObject("Scripting.FileSystemObject")

If fso.FileExists(file) Then
   fso.DeleteFile file, True
End If
Set fso = Nothing
End Function

Server.ScriptTimeOut=99999999
for x=1 to 2500000
Set xPost = CreateObject("Microsoft.XMLHTTP")
xPost.Open "GET",http://download.cmfu.com/pda/"&x&".txt,False
xPost.Send()
Set sGet = CreateObject("ADODB.Stream")
sGet.Mode = 3
sGet.Type = 1
sGet.Open()

sGet.Write (xPost.responseBody)
sGet.SaveToFile Server.MapPath("book\"&x&".htm"),2

dim s
s=ShowFileSize("book\"&x&".htm")

if s<=3 then
deletefile("book\"&x&".htm")
response.write "已删除 "&"book\"&x&".htm"
end if
response.write "<br>"
set sGet = nothing
set sPOST = nothing
'

'
next
%>

【code】存为x.asp 在此目录建立一个叫book的。。。然后就可以去睡觉了。。。


类别:Code||添加到搜藏 |分享到i贴吧|浏览(1310)|评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
     

   
帮助中心 | 空间客服 | 投诉中心 | 空间协议
©2012 Baidu