Collecting.asp
资源名称:eat.rar [点击查看]
上传用户:jisenq
上传日期:2014-06-29
资源大小:7216k
文件大小:35k
源码类别:
数据库编程
开发平台:
ASP/ASPX
- <% Option Explicit %>
- <!--#include file="../../FS_Inc/Const.asp" -->
- <!--#include file="../../FS_Inc/Function.asp"-->
- <!--#include file="inc/Function.asp"-->
- <!--#include file="../../FS_InterFace/MF_Function.asp" -->
- <%
- Dim Conn,CollectConn
- MF_Default_Conn
- MF_Collect_Conn
- MF_Session_TF
- Response.Buffer = true
- Response.Expires = -1
- Response.ExpiresAbsolute = Now() - 1
- Response.Expires = 0
- Response.CacheControl = "no-cache"
- Dim p_SYS_ROOT_DIR,SiteID,ErrorInfoStr,Action,SaveIMGPath,ListHeadSetting,ListFootSetting,LinkHeadSetting,LinkFootSetting
- Dim PagebodyHeadSetting,PagebodyFootSetting,PageTitleHeadSetting,PageTitleFootSetting,OtherPageFootSetting,OtherPageHeadSetting
- Dim OtherNewsPageHeadSetting,OtherNewsPageFootSetting,AuthorHeadSetting,AuthorFootSetting,SourceHeadSetting,SourceFootSetting
- Dim AddDateHeadSetting,AddDateFootSetting,IndexRule,StartPageNum,EndPageNum,HandPageContent,OtherType
- Dim IsStyle,IsDiv,IsA,IsClass,IsFont,IsSpan,IsObjectTF,IsIFrame,IsScript,HandSetAuthor,HandSetSource,HandSetAddDate,TextTF,SaveRemotePic,IsReverse
- Dim ObjURL,ReturnValue,CollectStartLocation,CollectEndFlag,CollectObjURL,CollectedPageURL,p_DoMain_Str
- Dim SiteName,CollectingSiteID,CollectSiteIndex,AllNewsNumber,CollectOKNumber,CollectPageNumber,Num,CollectType
- Dim OtherNewsType,OtherNewsPageIndexSetting,OtherNewsPageIndexSettingStartPageNum,OtherNewsPageIndexSettingEndPageNum,OtherNewsPageIndexSettingHandPageContent
- if G_VIRTUAL_ROOT_DIR = "" then
- p_SYS_ROOT_DIR = ""
- else
- p_SYS_ROOT_DIR = "/" & G_VIRTUAL_ROOT_DIR
- end if
- p_DoMain_Str = "http://"&Request.Cookies("FoosunMFCookies")("FoosunMFDomain")
- Action = Request("Action")
- SiteID = Request("SiteID")
- ErrorInfoStr = ""
- CollectEndFlag = False
- CollectedPageURL = Request("CollectedPageURL")
- AllNewsNumber = Request("AllNewsNumber")
- if AllNewsNumber = "" then
- AllNewsNumber = 0
- else
- AllNewsNumber = CLng(AllNewsNumber)
- end if
- CollectOKNumber = Request("CollectOKNumber")
- if CollectOKNumber = "" then
- CollectOKNumber = 0
- else
- CollectOKNumber = CLng(CollectOKNumber)
- end if
- CollectSiteIndex = Request("CollectSiteIndex")
- if CollectSiteIndex = "" then
- CollectSiteIndex = 0
- else
- CollectSiteIndex = CInt(CollectSiteIndex)
- end if
- CollectPageNumber = Request("CollectPageNumber")
- if CollectPageNumber = "" then
- CollectPageNumber = 0
- else
- CollectPageNumber = CInt(CollectPageNumber)
- end if
- CollectStartLocation = Request("CollectStartLocation")
- if CollectStartLocation = "" then CollectStartLocation = 0
- Num = Request("Num")
- If Num = "allNews" Or Num="" Then
- Num = 10
- Else
- if Not IsNumeric(Num) then
- Num = 10
- else
- Num = CInt(Num)
- end if
- End If
- CollectType = Request("CollectType")
- %>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
- <title>[site] 管理后台 -- 风讯内容管理系统 FoosunCMS V4.0</title>
- <link href="../images/skin/Css_<%=Session("Admin_Style_Num")%>/<%=Session("Admin_Style_Num")%>.css" rel="stylesheet" type="text/css">
- </head>
- <script language="JavaScript" src="js/PublicJS.js"></script>
- <body topmargin="2" leftmargin="2" oncontextmenu="//return false;">
- <table width="100%" border="0" cellpadding="1" cellspacing="1" class="table">
- <tr bgcolor="xingmu">
- <td height="26" colspan="5" valign="middle" class="hback">
- <table width="100%" height="20" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td style="cursor:hand;" width="35" id="StopCollect" align="center" alt="停止采集" onClick="location.href='Site.asp';" onMouseMove="BtnMouseOver(this);" onMouseOut="BtnMouseOver(this);" class="xingmu">取消</td>
- <td width=2 class="Gray">|</td>
- <td style="cursor:hand;" width="35" id="SaveCollect" align="center" alt="保存采集进度并返回" onClick="location.href='Site.asp';" onMouseMove="BtnMouseOver(this);" onMouseOut="BtnMouseOver(this);" class="xingmu">保存</td>
- <td width=2 class="Gray">|</td>
- <td style="cursor:hand;" width="35" align="center" alt="后退" onClick="history.back();" onMouseMove="BtnMouseOver(this);" onMouseOut="BtnMouseOver(this);" class="xingmu">后退</td>
- <td> </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- <table width="100%" border="0" cellpadding="5" cellspacing="1" class="tabble">
- <tr class="hback_1">
- <td height="20"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <%If CollectType="ResumeCollect" then%>
- <td width="50%;" align="right"><font color="#FF0000" id="CollectEndArea">正在续采</font></td>
- <%else%>
- <td width="50%;" align="right"><font color="#FF0000" id="CollectEndArea">正在采集</font></td>
- <%End if%>
- <td width="50%;"> <font color="#FF0000" id="ShowInfoArea" size="+1"> </font></td>
- </tr>
- </table></td>
- </tr>
- <tr>
- <td valign="middle" class="hback">
- <%
- if Action = "Submit" then
- if SiteID <> "" then
- GetCollectPara
- If AllNewsNumber>=Num And Num<>0 Then
- CollectEndFlag = True
- End If
- if CollectEndFlag then
- if ErrorInfoStr <> "" then
- Response.Write(ErrorInfoStr)
- else
- ReturnValue = "<br> <strong>采集结束</strong>: 共读取" & AllNewsNumber & "条新闻,采集成功" & CollectOKNumber & "条新闻。"
- Response.Write(ReturnValue)
- Response.Write("<script language=""JavaScript"">setTimeout('SetCollectEndStr();',100);</script>")
- end if
- elseif CollectType<>"ResumeCollect" Then
- GetNewsPageContent()
- if CollectStartLocation = 0 then
- ReturnValue = "<br> <strong><font color=red>采集分页" & CollectPageNumber & "</font></strong>:" & "<a target=""_blank"" href=""" & ObjURL & """>" & ObjURL & "</a><br>" & ReturnValue
- else
- ReturnValue = "<br> <strong><font color=red>采集分页" & CollectPageNumber + 1 & "</font></strong>:" & "<a target=""_blank"" href=""" & ObjURL & """>" & ObjURL & "</a><br>" & ReturnValue
- end if
- ReturnValue = "<br> <strong><font color=red>采集站点</font></strong>:" & SiteName & "<br>" & ReturnValue
- ReturnValue = "<br> <strong><font color=red>采集结果</font></strong>:已经读取" & AllNewsNumber & "条新闻,保存" & CollectOKNumber & "条新闻<br>" & ReturnValue
- Response.Write(ReturnValue & "<meta http-equiv=""refresh"" content=""2;url=Collecting.asp?Action=Submit&CollectPageNumber=" & CollectPageNumber & "&SiteID=" & SiteID & "&CollectStartLocation=" & CollectStartLocation & "&CollectedPageURL=" & CollectedPageURL & "&CollectSiteIndex=" & CollectSiteIndex & "&Num=" & Num & "&AllNewsNumber=" & AllNewsNumber & "&CollectOKNumber=" & CollectOKNumber & """>")
- else
- ResumeGetNewsPageContent()
- if CollectStartLocation = 0 then
- ReturnValue = "<br> <strong><font color=red>采集分页" & CollectPageNumber & "</font></strong>:" & "<a target=""_blank"" href=""" & ObjURL & """>" & ObjURL & "</a><br>" & ReturnValue
- else
- ReturnValue = "<br> <strong><font color=red>采集分页" & CollectPageNumber + 1 & "</font></strong>:" & "<a target=""_blank"" href=""" & ObjURL & """>" & ObjURL & "</a><br>" & ReturnValue
- end if
- ReturnValue = "<br> <strong><font color=red>采集站点</font></strong>:" & SiteName & "<br>" & ReturnValue
- ReturnValue = "<br> <strong><font color=red>采集结果</font></strong>:已经读取" & AllNewsNumber & "条新闻,续采了" & CollectOKNumber & "条新闻<br>" & ReturnValue
- Response.Write(ReturnValue & "<meta http-equiv=""refresh"" content=""2;url=Collecting.asp?Action=Submit&CollectType=ResumeCollect&CollectPageNumber=" & CollectPageNumber & "&SiteID=" & SiteID & "&CollectStartLocation=" & CollectStartLocation & "&CollectedPageURL=" & CollectedPageURL & "&CollectSiteIndex=" & CollectSiteIndex & "&AllNewsNumber=" & AllNewsNumber & "&CollectOKNumber=" & CollectOKNumber & """>")
- end if
- end if
- end if
- %>
- </td>
- </tr>
- </table>
- </body>
- </html>
- <script language="JavaScript">
- var ForwardShow=true;
- function ShowPromptInfo()
- {
- var TempStr=document.all.ShowInfoArea.innerText;
- if (ForwardShow==true)
- {
- if (TempStr.length>4) ForwardShow=false;
- document.all.ShowInfoArea.innerText=TempStr+'.';
- }
- else
- {
- if (TempStr.length==2) ForwardShow=true;
- document.all.ShowInfoArea.innerText=TempStr.substr(0,TempStr.length-1);
- }
- }
- function SetCollectEndStr()
- {
- document.all.CollectEndArea.innerText='采集结束,3秒钟后返回主页面';
- setTimeout("location='Site.asp';",3000);
- }
- window.setInterval('ShowPromptInfo()',500);</script>
- <% if Action = "" then %>
- <script language="JavaScript">
- setTimeout("location='?SiteID=<% = SiteID %>&CollectType=<%= CollectType %>&Action=Submit&Num=<%= Num %>';",10);
- </script>
- <% end if %>
- <%
- Set Conn = Nothing
- Set CollectConn = Nothing
- Function GetCollectPara()
- Dim RsSiteObj,Sql,SiteIDArray
- if SiteID = "" then
- ErrorInfoStr = "没有采集站点,请重试"
- Exit Function
- end if
- SiteIDArray = Split(SiteID,"***")
- if CollectSiteIndex > UBound(SiteIDArray) then
- CollectEndFlag = True
- Exit Function
- end if
- CollectingSiteID = SiteIDArray(CollectSiteIndex)
- Sql = "Select * from FS_Site where ID=" & CollectingSiteID
- Set RsSiteObj = CollectConn.Execute(Sql)
- if RsSiteObj.Eof then
- Set RsSiteObj = Nothing
- ErrorInfoStr = "没有采集站点,请重试"
- Exit Function
- else
- SiteName = RsSiteObj("SiteName")
- ListHeadSetting = RsSiteObj("ListHeadSetting")
- ListFootSetting = RsSiteObj("ListFootSetting")
- LinkHeadSetting = RsSiteObj("LinkHeadSetting")
- LinkFootSetting = RsSiteObj("LinkFootSetting")
- PagebodyHeadSetting = RsSiteObj("PagebodyHeadSetting")
- PagebodyFootSetting = RsSiteObj("PagebodyFootSetting")
- PageTitleHeadSetting = RsSiteObj("PageTitleHeadSetting")
- PageTitleFootSetting = RsSiteObj("PageTitleFootSetting")
- OtherPageFootSetting = RsSiteObj("OtherPageFootSetting")
- OtherPageHeadSetting = RsSiteObj("OtherPageHeadSetting")
- OtherNewsType = RsSiteObj("OtherNewsType")
- OtherNewsPageHeadSetting = RsSiteObj("OtherNewsPageHeadSetting")
- OtherNewsPageFootSetting = RsSiteObj("OtherNewsPageFootSetting")
- OtherNewsPageIndexSetting = RsSiteObj("OtherNewsPageIndexSetting")
- OtherNewsPageIndexSettingStartPageNum = RsSiteObj("OtherNewsPageIndexSettingStartPageNum")
- OtherNewsPageIndexSettingEndPageNum = RsSiteObj("OtherNewsPageIndexSettingEndPageNum")
- OtherNewsPageIndexSettingHandPageContent = RsSiteObj("OtherNewsPageIndexSettingHandPageContent")
- AuthorHeadSetting = RsSiteObj("AuthorHeadSetting")
- AuthorFootSetting = RsSiteObj("AuthorFootSetting")
- SourceHeadSetting = RsSiteObj("SourceHeadSetting")
- SourceFootSetting = RsSiteObj("SourceFootSetting")
- AddDateHeadSetting = RsSiteObj("AddDateHeadSetting")
- AddDateFootSetting = RsSiteObj("AddDateFootSetting")
- TextTF = RsSiteObj("TextTF")
- SaveRemotePic = RsSiteObj("SaveRemotePic")
- CollectObjURL = RsSiteObj("objURL")
- Dim p_Root_Path
- p_Root_Path = p_SYS_ROOT_DIR & "/" & G_UP_FILES_DIR & "/" & G_SAVE_FILE_PATH
- CreatePath Server.MapPath(p_Root_Path & "/" & Year(Date) & "-" & Month(Date) & "/" & Day(Date)),Server.MapPath(p_SYS_ROOT_DIR & "/" & G_UP_FILES_DIR)
- SaveIMGPath = p_Root_Path & "/" & Year(Date) & "-" & Month(Date) & "/" & Day(Date)
- IsStyle = RsSiteObj("IsStyle")
- IsDiv = RsSiteObj("IsDiv")
- IsA = RsSiteObj("IsA")
- IsClass = RsSiteObj("IsClass")
- IsFont = RsSiteObj("IsFont")
- IsSpan = RsSiteObj("IsSpan")
- IsObjectTF = RsSiteObj("IsObject")
- IsIFrame = RsSiteObj("IsIFrame")
- IsScript = RsSiteObj("IsScript")
- IndexRule = RsSiteObj("IndexRule")
- StartPageNum = RsSiteObj("StartPageNum")
- EndPageNum = RsSiteObj("EndPageNum")
- HandPageContent = RsSiteObj("HandPageContent")
- OtherType = RsSiteObj("OtherType")
- HandSetAuthor = RsSiteObj("HandSetAuthor")
- HandSetSource = RsSiteObj("HandSetSource")
- HandSetAddDate = RsSiteObj("HandSetAddDate")
- ObjURL = GetOtherURL(CollectPageNumber,RsSiteObj)
- IsReverse=RsSiteObj("IsReverse")
- if ObjURL = "" then
- CollectPageNumber = 0
- CollectStartLocation = 0
- CollectedPageURL = ""
- CollectSiteIndex = CollectSiteIndex + 1
- Set RsSiteObj = Nothing
- GetCollectPara
- Exit Function
- else
- if CollectPageNumber > G_NEWS_LIST_PAGES_NUMBER then
- CollectPageNumber = 0
- CollectStartLocation = 0
- CollectedPageURL = ""
- CollectSiteIndex = CollectSiteIndex + 1
- Set RsSiteObj = Nothing
- GetCollectPara
- Exit Function
- end if
- end if
- end if
- Set RsSiteObj = Nothing
- End Function
- Function GetOtherURL(PageNum,Obj) '取得其他新闻列表的URL
- Dim OtherObjURL,OtherResponseAllStr,OtherNewsListArray,i
- if PageNum = 0 then
- GetOtherURL = CollectObjURL
- CollectedPageURL = ""
- else
- Select Case OtherType
- Case 0 '不分页
- GetOtherURL = ""
- Case 1 '标记分页
- if IsNull(OtherPageHeadSetting) OR IsNull(OtherPageFootSetting) OR (OtherPageFootSetting = "") OR (OtherPageHeadSetting = "") then
- GetOtherURL = ""
- else
- if PageNum = 1 then
- CollectedPageURL = CollectObjURL
- end if
- OtherResponseAllStr = GetPageContent(FormatUrl(CollectedPageURL,CollectObjURL))
- OtherObjURL = GetOtherContent(OtherResponseAllStr,OtherPageHeadSetting,OtherPageFootSetting)
- if OtherObjURL <> "" then
- OtherObjURL = FormatUrl(OtherObjURL,CollectObjURL)
- else
- OtherObjURL = ""
- end if
- GetOtherURL = OtherObjURL
- end if
- Case 2 '索引分页
- if IsNull(IndexRule) OR (IndexRule = "") OR IsNull(StartPageNum) OR (StartPageNum = "") OR IsNull(EndPageNum) OR (EndPageNum = "") then
- GetOtherURL = ""
- else
- if Not IsNumeric(StartPageNum) OR Not IsNumeric(EndPageNum) then
- GetOtherURL = ""
- else
- if CInt(StartPageNum) < CInt(EndPageNum) Then '按从小到大的页数
- if PageNum >= CInt(EndPageNum) then
- GetOtherURL = ""
- else
- if PageNum = 1 then
- IndexRule = Replace(FormatUrl(IndexRule,CollectObjURL),"^$^",StartPageNum)
- else
- StartPageNum = CInt(StartPageNum) + PageNum - 1
- IndexRule = Replace(FormatUrl(IndexRule,CollectObjURL),"^$^",StartPageNum)
- end if
- GetOtherURL = IndexRule
- end if
- Else '按从大到小的页数,从而实现倒序采集,比如从10到1
- if PageNum >= CInt(StartPageNum) then
- GetOtherURL = ""
- else
- if PageNum = 1 then
- IndexRule = Replace(FormatUrl(IndexRule,CollectObjURL),"^$^",StartPageNum)
- else
- EndPageNum = CInt(StartPageNum) - PageNum + 1
- IndexRule = Replace(FormatUrl(IndexRule,CollectObjURL),"^$^",EndPageNum)
- end if
- GetOtherURL = IndexRule
- end if
- end if
- end if
- end if
- Case 3 '手工分页
- if IsNull(HandPageContent) OR (HandPageContent = "") then
- GetOtherURL = ""
- ElseIf InStr(HandPageContent,Chr(10))=0 And PageNum<2 Then
- GetOtherURL = HandPageContent
- Else
- HandPageContent = Split(HandPageContent,Chr(10))
- if PageNum > UBound(HandPageContent) then
- GetOtherURL = ""
- else
- if HandPageContent(PageNum - 1) <> "" then
- GetOtherURL = HandPageContent(PageNum - 1)
- else
- GetOtherURL = ""
- end if
- end if
- end if
- Case Else
- GetOtherURL = ""
- End Select
- end if
- End Function
- Function GetNewsPageContent()
- Dim NewsPageStr,TitleStr,ContentStr,AuthorStr,SourceStr,AddDate,i
- Dim ResponseAllStr,NewsListStr,NewsLinkStr,RsCheckNewsObj
- Dim NewsListStrArray,TempArray
- ResponseAllStr = GetPageContent(FormatUrl(ObjURL,CollectObjURL))
- if ResponseAllStr = False then
- CollectPageNumber = CollectPageNumber + 1
- ReturnValue = ReturnValue & "<br> <strong>错误</strong>:读取新闻列表页面失败<br>"
- Exit Function
- end if
- Dim BLinkHeadSetting,BLinkFootSetting
- BLinkHeadSetting = False
- BLinkFootSetting = False
- If Instr(LinkHeadSetting,"[变量]")<=0 Then
- BLinkHeadSetting = True
- ElseIf Instr(LinkFootSetting,"[变量]")<=0 Then
- BLinkFootSetting = True
- End If
- If InStr(ResponseAllStr,ListHeadSetting)>0 And InStr(ResponseAllStr,ListFootSetting) <> 0 Then
- NewsListStr = GetOtherContent(ResponseAllStr,ListHeadSetting,ListFootSetting)
- Else
- NewsListStr = ResponseAllStr
- End If
- If BLinkHeadSetting Then
- NewsListStr = Mid(NewsListStr,Instr(NewsListStr,LinkHeadSetting)+len(LinkHeadSetting))
- NewsListStrArray = Split(NewsListStr,LinkHeadSetting)
- elseif BLinkFootSetting Then
- NewsListStr = Left(NewsListStr,InstrRev(NewsListStr,LinkFootSetting))
- NewsListStrArray = Split(NewsListStr,LinkFootSetting)
- else
- NewsListStrArray = Array("")
- End If
- '倒序采集
- If IsReverse="1" then
- Dim TempArr,j
- TempArr=NewsListStrArray
- For j =0 to UBound(NewsListStrArray)
- NewsListStrArray(j)=TempArr(UBound(NewsListStrArray)-j)
- Next
- If Num>0 And Num-1<=UBound(NewsListStrArray) Then
- TempArr=NewsListStrArray
- For j =0 to Num-1 'UBound(NewsListStrArray)
- NewsListStrArray(j)=TempArr(UBound(NewsListStrArray)-Num+j+1)
- Next
- End If
- End If
- For i = CollectStartLocation to CollectStartLocation + CollectMaxOfOnePage - 1
- if i > UBound(NewsListStrArray) Or (i >= Num And Num<>0) then
- CollectPageNumber = CollectPageNumber + 1
- CollectStartLocation = 0
- CollectedPageURL = ObjURL
- Exit Function
- end If
- AllNewsNumber = AllNewsNumber + 1
- if NewsListStrArray(i) <> "" then
- If BLinkHeadSetting=True Then
- TempArray = GetOtherContent(LinkHeadSetting&NewsListStrArray(i),LinkHeadSetting,LinkFootSetting)
- ElseIf BLinkFootSetting=True Then
- TempArray = GetOtherContent(NewsListStrArray(i)&LinkFootSetting,LinkHeadSetting,LinkFootSetting)
- End If
- if TempArray <> "" Then
- NewsLinkStr = LoseHtml(FormatUrl(TempArray,CollectObjURL))
- NewsPageStr = GetPageContent(NewsLinkStr)
- if NewsPageStr <> False then
- TitleStr = LoseHtml(GetOtherContent(NewsPageStr,PageTitleHeadSetting,PageTitleFootSetting))
- Set RsCheckNewsObj = CollectConn.Execute("Select * from FS_News where Links='" & NewsLinkStr & "'")
- if Not RsCheckNewsObj.Eof then
- ReturnValue = GetOneNewsReturnValue(1,i + 1,TitleStr,"",NewsLinkStr) & ReturnValue
- else
- ContentStr = ReplaceKeyWords(GetOneNewsContent(NewsPageStr,NewsLinkStr))
- ContentStr = ReplaceContentStr(ContentStr)
- if SaveRemotePic then ContentStr = ReplaceIMGRemoteUrl(ContentStr,SaveIMGPath,p_DoMain_Str,p_SYS_ROOT_DIR,NewsLinkStr,SaveRemotePic)
- if TitleStr = "" then
- ReturnValue = GetOneNewsReturnValue(2,i + 1,"","",NewsLinkStr) & ReturnValue
- elseif ContentStr = "" then
- ReturnValue = GetOneNewsReturnValue(3,i + 1,TitleStr,"",NewsLinkStr) & ReturnValue
- else
- ReturnValue = GetOneNewsReturnValue(4,i + 1,TitleStr,ContentStr,NewsLinkStr) & ReturnValue
- if IsNull(HandSetAuthor) OR (HandSetAuthor = "") then
- AuthorStr = LoseHtml(GetOtherContent(NewsPageStr,AuthorHeadSetting,AuthorFootSetting))
- else
- AuthorStr = HandSetAuthor
- end if
- if IsNull(HandSetSource) OR (HandSetSource = "") then
- SourceStr = LoseHtml(GetOtherContent(NewsPageStr,SourceHeadSetting,SourceFootSetting))
- else
- SourceStr = HandSetSource
- end if
- if IsNull(HandSetAddDate) OR Not IsDate(HandSetSource) then
- AddDate = LoseHtml(GetOtherContent(NewsPageStr,AddDateHeadSetting,AddDateFootSetting))
- else
- AddDate = HandSetSource
- end if
- if AddDate <> "" then
- if Not IsDate(AddDate) then AddDate = Now
- else
- AddDate = Now
- end if
- SaveCollectContent TitleStr,NewsLinkStr,ContentStr,AuthorStr,SourceStr,AddDate
- end if
- end if
- Set RsCheckNewsObj = Nothing
- else
- ReturnValue = GetOneNewsReturnValue(5,i + 1,"","",NewsLinkStr) & ReturnValue
- end if
- else
- ReturnValue = GetOneNewsReturnValue(5,i + 1,"","",NewsLinkStr) & ReturnValue
- end if
- else
- ReturnValue = GetOneNewsReturnValue(5,i + 1,"","",NewsLinkStr) & ReturnValue
- end if
- Next
- CollectStartLocation = i
- End Function
- Function ResumeGetNewsPageContent()
- dim ResumeSql,RsResumeNewsObj,ResumeNewsURL,ResumeNewsURL1,ResumeNewsLocation
- ResumeSql = "Select top 1 Links from FS_News where SiteID='" & CollectingSiteID &"' order by ID DESC"
- Set RsResumeNewsObj = CollectConn.Execute(ResumeSql)
- If RsResumeNewsObj.EOF Then
- set RsResumeNewsObj = nothing
- response.Write("<script>alert(""无法确定您以前的采集记录,n续采失败!"");history.go(-2);</script>")
- else
- ResumeNewsURL = RsResumeNewsObj("Links")
- set RsResumeNewsObj = nothing
- End If
- Dim NewsPageStr,TitleStr,ContentStr,AuthorStr,SourceStr,AddDate,i,n
- Dim ResponseAllStr,NewsListStr,NewsLinkStr,RsCheckNewsObj
- Dim NewsListStrArray,TempArray
- ResponseAllStr = GetPageContent(FormatUrl(ObjURL,CollectObjURL))
- if ResponseAllStr = False then
- CollectPageNumber = CollectPageNumber + 1
- ReturnValue = ReturnValue & "<br> <strong>错误</strong>:读取新闻列表页面失败<br>"
- Exit Function
- end if
- Dim BLinkHeadSetting,BLinkFootSetting
- BLinkHeadSetting = False
- BLinkFootSetting = False
- If Instr(LinkHeadSetting,"[变量]")<=0 Then
- BLinkHeadSetting = True
- elseif Instr(LinkFootSetting,"[变量]")<=0 Then
- BLinkFootSetting = True
- End If
- If InStr(ResponseAllStr,ListHeadSetting)>0 And InStr(ResponseAllStr,ListFootSetting) Then
- NewsListStr = GetOtherContent(ResponseAllStr,ListHeadSetting,ListFootSetting)
- Else
- NewsListStr = ResponseAllStr
- End If
- If BLinkHeadSetting Then
- NewsListStr = Mid(NewsListStr,Instr(NewsListStr,LinkHeadSetting)+len(LinkHeadSetting))
- NewsListStrArray = Split(NewsListStr,LinkHeadSetting)
- elseif BLinkFootSetting Then
- NewsListStr = Left(NewsListStr,InstrRev(NewsListStr,LinkFootSetting))
- NewsListStrArray = Split(NewsListStr,LinkFootSetting)
- End If
- For n = 0 to UBound(NewsListStrArray)
- Dim tempURL
- tempURL=LoseHtml(FormatUrl(GetOtherContent(LinkHeadSetting&NewsListStrArray(n),LinkHeadSetting,LinkFootSetting),CollectObjURL))
- If ResumeNewsURL = tempURL Then
- Exit For
- ElseIf n>=UBound(NewsListStrArray) Then
- AllNewsNumber = AllNewsNumber+n
- CollectPageNumber = CollectPageNumber + 1
- CollectStartLocation = 0
- CollectedPageURL = ObjURL
- Exit Function
- End If
- Next
- CollectStartLocation = n+1
- If IsReverse="1" then '倒序采集
- Dim TempArr,j
- TempArr=NewsListStrArray
- For j =0 to UBound(NewsListStrArray)
- NewsListStrArray(j)=TempArr(UBound(NewsListStrArray)-j)
- Next
- End If
- For i = CollectStartLocation to CollectStartLocation + CollectMaxOfOnePage - 1
- if i > UBound(NewsListStrArray) Then
- CollectPageNumber = CollectPageNumber + 1
- CollectStartLocation = 0
- CollectedPageURL = ObjURL
- Exit Function
- end If
- AllNewsNumber = AllNewsNumber + 1
- If BLinkHeadSetting Then
- TempArray = GetOtherContent(LinkHeadSetting&NewsListStrArray(i),LinkHeadSetting,LinkFootSetting)
- elseif BLinkFootSetting Then
- TempArray = GetOtherContent(NewsListStrArray(i)&LinkFootSetting,LinkHeadSetting,LinkFootSetting)
- End If
- if TempArray <> "" Then
- NewsLinkStr = LoseHtml(FormatUrl(TempArray,CollectObjURL))
- Set RsCheckNewsObj = CollectConn.Execute("Select * from FS_News where Links='" & NewsLinkStr & "'")
- if RsCheckNewsObj.Eof then
- NewsPageStr = GetPageContent(NewsLinkStr)
- if NewsPageStr <> False then
- TitleStr = LoseHtml(GetOtherContent(NewsPageStr,PageTitleHeadSetting,PageTitleFootSetting))
- Set RsCheckNewsObj = CollectConn.Execute("Select * from FS_News where Links='" & NewsLinkStr & "'")
- ContentStr = ReplaceKeyWords(GetOneNewsContent(NewsPageStr,NewsLinkStr))
- ContentStr = ReplaceContentStr(ContentStr)
- if SaveRemotePic then ContentStr = ReplaceIMGRemoteUrl(ContentStr,SaveIMGPath,p_DoMain_Str,p_SYS_ROOT_DIR,NewsLinkStr,SaveRemotePic)
- if TitleStr = "" then
- ReturnValue = GetOneNewsReturnValue(2,i + 1,"","",NewsLinkStr) & ReturnValue
- elseif ContentStr = "" then
- ReturnValue = GetOneNewsReturnValue(3,i + 1,TitleStr,"",NewsLinkStr) & ReturnValue
- else
- ReturnValue = GetOneNewsReturnValue(4,i + 1,TitleStr,ContentStr,NewsLinkStr) & ReturnValue
- if IsNull(HandSetAuthor) OR (HandSetAuthor = "") then
- AuthorStr = LoseHtml(GetOtherContent(NewsPageStr,AuthorHeadSetting,AuthorFootSetting))
- else
- AuthorStr = HandSetAuthor
- end if
- if IsNull(HandSetSource) OR (HandSetSource = "") then
- SourceStr = LoseHtml(GetOtherContent(NewsPageStr,SourceHeadSetting,SourceFootSetting))
- else
- SourceStr = HandSetSource
- end if
- if IsNull(HandSetAddDate) OR Not IsDate(HandSetSource) then
- AddDate = LoseHtml(GetOtherContent(NewsPageStr,AddDateHeadSetting,AddDateFootSetting))
- else
- AddDate = HandSetSource
- end if
- if AddDate <> "" then
- if Not IsDate(AddDate) then AddDate = Now
- else
- AddDate = Now
- end if
- SaveCollectContent TitleStr,NewsLinkStr,ContentStr,AuthorStr,SourceStr,AddDate
- end if
- Set RsCheckNewsObj = Nothing
- else
- ReturnValue = GetOneNewsReturnValue(5,i + 1,"","",NewsLinkStr) & ReturnValue
- End If
- ElseIf session("ConfirmCollectRevert")<>"ConfirmCollectRevert" Then
- session("ConfirmCollectRevert") = "ConfirmCollectRevert"
- response.write("<script>if(confirm(""您改变过采集顺序吗?n如果修改过,请单击确定改回原样再续采!n没有修改过请单击取消继续!""))window.location=""site.asp""</script>")
- End If
- End If
- Next
- CollectStartLocation = i
- End Function
- Function GetOneNewsContent(FirstPageContent,NewsLinkStr)
- Dim OtherPageNewsLink,OtherPageNewsContentStr,tempSplitArr1,tempSplitArr2
- Dim f_Collect_Index,f_Temp_Array,f_URL,f_Start,f_End,f_Int,f_I
- 'On Error Resume Next
- f_Collect_Index = 0
- OtherPageNewsContentStr = FirstPageContent
- GetOneNewsContent = GetOtherContent(FirstPageContent,PagebodyHeadSetting,PagebodyFootSetting)
- Select Case OtherNewsType
- Case 0
- Case 1
- if IsNull(OtherNewsPageHeadSetting) OR IsNull(OtherNewsPageFootSetting) OR (OtherNewsPageHeadSetting = "") OR (OtherNewsPageFootSetting = "") Then
- OtherPageNewsLink = ""
- ElseIf InStr(OtherPageNewsContentStr,OtherNewsPageFootSetting)>0 And InStr(OtherPageNewsContentStr,OtherNewsPageHeadSetting)>0 Then
- tempSplitArr1 = Split(OtherPageNewsContentStr,OtherNewsPageHeadSetting)
- tempSplitArr2 = Split(tempSplitArr1(1),OtherNewsPageFootSetting)
- OtherPageNewsLink = tempSplitArr2(0)
- Else
- OtherPageNewsLink = GetOtherContent(OtherPageNewsContentStr,OtherNewsPageHeadSetting,OtherNewsPageFootSetting)
- End If
- Do While (OtherPageNewsLink <> "")
- OtherPageNewsLink = FormatUrl(OtherPageNewsLink,NewsLinkStr)
- OtherPageNewsContentStr = GetPageContent(OtherPageNewsLink)
- If InStr(OtherPageNewsContentStr,OtherNewsPageFootSetting)>0 And InStr(OtherPageNewsContentStr,OtherNewsPageHeadSetting)>0 Then
- tempSplitArr1 = Split(OtherPageNewsContentStr,OtherNewsPageHeadSetting)
- tempSplitArr2 = Split(tempSplitArr1(1),OtherNewsPageFootSetting)
- OtherPageNewsLink = tempSplitArr2(0)
- Else
- OtherPageNewsLink = GetOtherContent(OtherPageNewsContentStr,OtherNewsPageHeadSetting,OtherNewsPageFootSetting)
- End If
- If OtherPageNewsContentStr<>False Then
- GetOneNewsContent = GetOneNewsContent & "[Page]" & GetOtherContent(OtherPageNewsContentStr,PagebodyHeadSetting,PagebodyFootSetting)
- Else
- OtherPageNewsLink = ""
- End If
- If Err Then
- Err.clear
- OtherPageNewsLink = ""
- End If
- Loop
- Case 2
- if IsNull(OtherNewsPageIndexSetting) OR (OtherNewsPageIndexSetting = "") OR IsNull(OtherNewsPageIndexSettingStartPageNum) OR (OtherNewsPageIndexSettingStartPageNum = "") OR IsNull(OtherNewsPageIndexSettingEndPageNum) OR (OtherNewsPageIndexSettingEndPageNum = "") then
- else
- if Not IsNumeric(OtherNewsPageIndexSettingStartPageNum) OR Not IsNumeric(OtherNewsPageIndexSettingEndPageNum) then
- else
- f_Start = CInt(OtherNewsPageIndexSettingStartPageNum)
- f_End = CInt(OtherNewsPageIndexSettingEndPageNum)
- if f_Start > f_End Then
- f_Int = f_Start
- f_Start = f_End
- f_End = f_Int
- end if
- do while f_Start + f_Collect_Index <= f_End
- f_URL = Replace(FormatUrl(OtherNewsPageIndexSetting,CollectObjURL),"^$^",f_Start + f_Collect_Index)
- OtherPageNewsLink = FormatUrl(f_URL,NewsLinkStr)
- OtherPageNewsContentStr = GetPageContent(OtherPageNewsLink)
- If InStr(OtherPageNewsContentStr,OtherNewsPageFootSetting)>0 And InStr(OtherPageNewsContentStr,OtherNewsPageHeadSetting)>0 Then
- tempSplitArr1 = Split(OtherPageNewsContentStr,OtherNewsPageHeadSetting)
- tempSplitArr2 = Split(tempSplitArr1(1),OtherNewsPageFootSetting)
- OtherPageNewsLink = tempSplitArr2(0)
- Else
- OtherPageNewsLink = GetOtherContent(OtherPageNewsContentStr,OtherNewsPageHeadSetting,OtherNewsPageFootSetting)
- End If
- If OtherPageNewsContentStr <> False Then GetOneNewsContent = GetOneNewsContent & "[Page]" & GetOtherContent(OtherPageNewsContentStr,PagebodyHeadSetting,PagebodyFootSetting)
- If Err Then Err.clear
- f_Collect_Index = f_Collect_Index + 1
- Loop
- end if
- end if
- Case 3 '手工分页
- if IsNull(OtherNewsPageIndexSettingHandPageContent) OR (OtherNewsPageIndexSettingHandPageContent = "") then
- Else
- f_Temp_Array = Split(OtherNewsPageIndexSettingHandPageContent,Chr(10))
- for f_I = LBound(f_Temp_Array) to UBound(f_Temp_Array)
- if f_Temp_Array(f_I) <> "" then
- OtherPageNewsLink = FormatUrl(f_Temp_Array(f_I),NewsLinkStr)
- OtherPageNewsContentStr = GetPageContent(OtherPageNewsLink)
- If InStr(OtherPageNewsContentStr,OtherNewsPageFootSetting)>0 And InStr(OtherPageNewsContentStr,OtherNewsPageHeadSetting)>0 Then
- tempSplitArr1 = Split(OtherPageNewsContentStr,OtherNewsPageHeadSetting)
- tempSplitArr2 = Split(tempSplitArr1(1),OtherNewsPageFootSetting)
- OtherPageNewsLink = tempSplitArr2(0)
- Else
- OtherPageNewsLink = GetOtherContent(OtherPageNewsContentStr,OtherNewsPageHeadSetting,OtherNewsPageFootSetting)
- End If
- If OtherPageNewsContentStr <> False Then GetOneNewsContent = GetOneNewsContent & "[Page]" & GetOtherContent(OtherPageNewsContentStr,PagebodyHeadSetting,PagebodyFootSetting)
- If Err Then Err.clear
- end if
- Next
- end if
- Case Else
- End Select
- End Function
- Function GetOneNewsReturnValue(CauseIndex,NewsIndex,Title,Content,LinkStr)
- Select Case CauseIndex
- Case 1 '不允许重名保存
- GetOneNewsReturnValue = "</br> <strong>序号</strong>: " & NewsIndex
- GetOneNewsReturnValue = GetOneNewsReturnValue & " <strong>结果</strong>: <font color=red>已经采集,在等待审核或者在历史纪录里面</font>"
- GetOneNewsReturnValue = GetOneNewsReturnValue & "<br> <strong>标题</strong>: " & Title
- GetOneNewsReturnValue = GetOneNewsReturnValue & "<br> <strong>新闻链接</strong>: <a target=""_blank"" href=""" & LinkStr & """>" & LinkStr & "</a><br>"
- Case 2 '标题为空,没有保存
- GetOneNewsReturnValue = "</br> <strong>序号</strong>: " & NewsIndex
- GetOneNewsReturnValue = GetOneNewsReturnValue & " <strong>结果</strong>: <font color=red>标题为空,没有保存</font>"
- GetOneNewsReturnValue = GetOneNewsReturnValue & "<br> <strong>新闻链接</strong>: <a target=""_blank"" href=""" & LinkStr & """>" & LinkStr & "</a><br>"
- Case 3 '内容为空,没有保存
- GetOneNewsReturnValue = "</br> <strong>序号</strong>: " & NewsIndex
- GetOneNewsReturnValue = GetOneNewsReturnValue & " <strong>结果</strong>: <font color=red>内容为空,没有保存</font>"
- GetOneNewsReturnValue = GetOneNewsReturnValue & "<br> <strong>标题</strong>: " & Title
- GetOneNewsReturnValue = GetOneNewsReturnValue & "<br> <strong>新闻链接</strong>: <a target=""_blank"" href=""" & LinkStr & """>" & LinkStr & "</a><br>"
- Case 4 '成功保存
- GetOneNewsReturnValue = "</br> <strong>序号</strong>: " & NewsIndex
- GetOneNewsReturnValue = GetOneNewsReturnValue & " <strong>结果</strong>: 采集成功"
- GetOneNewsReturnValue = GetOneNewsReturnValue & "<br> <strong>标题</strong>: " & Title
- GetOneNewsReturnValue = GetOneNewsReturnValue & "<br> <strong>内容</strong>: " & Left(LoseHtml(Content),30) & " ......"
- GetOneNewsReturnValue = GetOneNewsReturnValue & "<br> <strong>新闻链接</strong>: <a target=""_blank"" href=""" & LinkStr & """>" & LinkStr & "</a><br>"
- CollectOKNumber = CollectOKNumber + 1
- Case 5 '不能够读取新闻目标页面
- GetOneNewsReturnValue = "</br> <strong>序号</strong>: " & NewsIndex
- GetOneNewsReturnValue = GetOneNewsReturnValue & " <strong>结果</strong>: <font color=red>不能够读取新闻目标页面</font>"
- GetOneNewsReturnValue = GetOneNewsReturnValue & "<br> <strong>新闻链接</strong>: <a target=""_blank"" href=""" & LinkStr & """>" & LinkStr & "</a><br>"
- Case else
- End Select
- End Function
- Function SaveCollectContent(Title,Links,Content,Author,SourceString,AddDate)
- Dim RsNewsObj,RsTempObj
- Set RsNewsObj = Server.CreateObject("Adodb.RecordSet")
- RsNewsObj.Open "Select * from FS_News where 1=0",CollectConn,3,3
- RsNewsObj.AddNew
- RsNewsObj("Title") = LoseHtml(Title)
- RsNewsObj("Links") = Links
- RsNewsObj("Content") = Content
- RsNewsObj("ContentLength") = Len(Content)
- RsNewsObj("AddDate") = AddDate
- RsNewsObj("ImagesCount") = 0
- RsNewsObj("SiteID") = CollectingSiteID
- RsNewsObj("Author") = Left(Author,200)
- RsNewsObj("IsLock") = 0
- RsNewsObj("History") = 0
- RsNewsObj("Source") = Left(SourceString,200)
- RsNewsObj("ReviewTF") = 0
- RsNewsObj.UpDate
- RsNewsObj.Close
- Set RsNewsObj = Nothing
- End Function
- Function ReplaceKeyWords(Content)
- Dim RsRuleObj,HeadSeting,FootSeting,ReContent,regEx
- Set RsRuleObj = CollectConn.Execute("Select * from FS_Rule where SiteID=" & CollectingSiteID)
- do while Not RsRuleObj.Eof
- HeadSeting = RsRuleObj("HeadSeting")
- FootSeting = RsRuleObj("FootSeting")
- ReContent = RsRuleObj("ReContent")
- if IsNull(FootSeting) or FootSeting = "" then
- if HeadSeting <> "" then
- Content = Replace(Content,HeadSeting,ReContent)
- end if
- end if
- if Not IsNull(FootSeting) and FootSeting <> "" and Not IsNull(HeadSeting) and HeadSeting <> "" then
- Set regEx = New RegExp
- regEx.Pattern = HeadSeting & "[^ ]*" & FootSeting
- regEx.IgnoreCase = False
- regEx.Global = True
- 'Dim Matches,Match,HaveTF,ShowStr
- 'HaveTF = False
- 'Set Matches = regEx.Execute(Content)
- 'For Each Match in Matches
- 'ShowStr = ShowStr & Match.Value & "<br>"
- 'HaveTF = True
- 'Next
- 'if HaveTF = True then
- 'Response.Write(ShowStr)
- 'Response.End
- 'end if
- if IsNull(ReContent) then
- Content = regEx.Replace(Content,"")
- else
- Content = regEx.Replace(Content,ReContent)
- end if
- Set regEx = Nothing
- end if
- RsRuleObj.MoveNext
- loop
- Set RsRuleObj = Nothing
- ReplaceKeyWords = Content
- End Function
- %>