一个带采集远程文章内容,保存图片,生成文件等完整的采集功能

2019-04-01 19:46:23王冬梅

if not fso.fileExists(server.mappath(filename)) then exit function
set f = fso.opentextfile(server.mappath(filename),1)
if not f.AtEndofStream then
tempcnt = f.readall
f.close
set f = nothing
temparray = split(tempcnt,chr(13)&chr(10))
if lineNum>ubound(temparray)+1 then
exit function
else
FSOlinedit = temparray(lineNum-1)
end if
end if
end function

'**************************************************
'函数名:FSOlinewrite
'作 用:使用FSO写文件某一行的函数
'参 数:filename ----文件名称
' lineNum ----行数
' Linecontent ----内容
'返回值:无
'**************************************************
function FSOlinewrite(filename,lineNum,Linecontent)
if linenum < 1 then exit function
dim fso,f,temparray,tempCnt
set fso = server.CreateObject("scripting.filesystemobject")
if not fso.fileExists(server.mappath(filename)) then exit function
set f = fso.opentextfile(server.mappath(filename),1)
if not f.AtEndofStream then
tempcnt = f.readall
f.close
temparray = split(tempcnt,chr(13)&chr(10))
if lineNum>ubound(temparray)+1 then
exit function
else
temparray(lineNum-1) = lineContent
end if
tempcnt = join(temparray,chr(13)&chr(10))
set f = fso.createtextfile(server.mappath(filename),true)
f.write tempcnt
end if
f.close
set f = nothing
end function

'**************************************************
'函数名:Htmlmake
'作 用:使用FSO创建文件
'参 数:HtmlFolder ----路径
' HtmlFilename ----文件名
' HtmlContent ----内容
'**************************************************
function Htmlmake(HtmlFolder,HtmlFilename,HtmlContent)
On Error Resume Next
dim filepath,fso,fout
filepath = HtmlFolder&"/"&HtmlFilename
Set fso = Server.CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(HtmlFolder) Then
Else
CreateMultiFolder(HtmlFolder)
&, ;nbs, p; End If
Set fout = fso.Createtextfile(server.mappath(filepath),true)
fout.writeline HtmlContent
fout.close
set fso=nothing
Set fso = Server.CreateObject("Scripting.FileSystemObject")
If fso.fileexists(Server.MapPath(filepath)) Then
Response.Write "文件<font color=red>"&HtmlFilename&"</font>已生成!<br>"
Else
'Response.Write Server.MapPath(filepath)
Response.Write "文件<font color=red>"&HtmlFilename&"</font>未生成!<br>"
End If
Set fso = nothing
End function

'**************************************************
'函数名:Htmldel
'作 用:使用FSO删除文件
'参 数:HtmlFolder ----路径
' HtmlFilename ----文件名
'**************************************************
Sub Htmldel(HtmlFolder,HtmlFilename)
dim filepath,fso
filepath = HtmlFolder&"/"&HtmlFilename
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(Server.mappath(filepath))