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

2019-01-13 08:00:14丽君

'response.Write PhCreateFolderSub&"<br>"

If Not objFSO.FolderExists(PhCreateFolderSub) Then
objFSO.CreateFolder(PhCreateFolderSub)
End If
Next
If Err Then
Err.Clear()
Else
BlInfo = True
End If
Set objFSO=nothing
CreateMultiFolder = BlInfo
End Function

'**************************************************
'函数名:FSOFileRead
'作 用:使用FSO读取文件内容的函数
'参 数:filename ----文件名称
'返回值:文件内容
'**************************************************
function FSOFileRead(filename)
Dim objFSO,objCountFile,FiletempData
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)
FSOFileRead = objCountFile.ReadAll
objCountFile.Close
Set objCountFile=Nothing
Set objFSO = Nothing
End Function

'**************************************************
'函数名:FSOlinedit
'作 用:使用FSO读取文件某一行的函数
'参 数:filename ----文件名称
' lineNum ----行数
'返回值:文件该行内容
'**************************************************
function FSOlinedit(filename,lineNum)
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
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