<html><!--#include file="../QvodCms_Conn.asp"-->
<head><!--#include file="QvodCms_Caiji_Inc.asp" --><!--#include file="CaiJi_Conn.asp"-->
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<TITLE>采集页面</TITLE>
<style type="text/css">body {background:#f3f9fb; font-size:12px;SCROLLBAR-FACE-COLOR: #37b2e9; SCROLLBAR-HIGHLIGHT-COLOR: #1d90cd; SCROLLBAR-SHADOW-COLOR: #1d90cd; SCROLLBAR-DARKSHADOW-COLOR: #1d90cd; SCROLLBAR-3DLIGHT-COLOR: #1d90cd; SCROLLBAR-ARROW-COLOR: #eef7fb;SCROLLBAR-TRACK-COLOR: #1d90cd; }</style>
</head>
<body>
<%
Dim Action,ListUrl,UserId,KeyId,KeyIp,repage,stapage,endpage,dataid,qiangzi,shuju,Dayid,keyword,cj_data_year
Dim cj_data_id,cj_class_id,cj_data_name,cj_data_actor,cj_data_director,cj_data_erea,cj_data_hits,cj_data_status,cj_data_picurl,cj_data_intro,cj_data_reurl,cj_data_language,cj_UpdateTime,cj_data_playpath,cj_data_playurl,class_id,cj_data_time
Dim ida,idb,i,j
repage=Request.ServerVariables("Http_Referer")
action=Trim(Request.QueryString("action"))
ListUrl=Trim(Request.QueryString("Url"))'站点
dataid=Trim(Request("data_id"))'全选/反选ID
qiangzi=Trim(Request("pd"))'强制更新参数设置
shuju=Cint(Request("sj"))'数据更新处理方式
keyword=Request.QueryString("keyword")'数据搜索		
UserKey=AdminId(3)'验证授权码
Userweb=Request.ServerVariables("Http_Host")'验证域名
UpdateTime=Request.QueryString("UpdateTime")'选择日期
Call OpenConn()
If action="update" Then'勾选ID
  Response.Write("<div style='font-size:12px'>")
   If dataid="" Then
	  Response.Write("请至少选择一个您要采集的影片!")
	  Response.End
   ElseIf Instr(dataid,",")>0 Then '多个影片ID
	  ida=split(dataid,", ")
	  idb=ubound(ida)
	  Response.Write "本次共需要采集影片<span style='font-size:21px;font-weight:bold;color:#FF0000'>"&(idb+1)&"</span>个 <a href='"&repage&"'>返回上一页</a>"
	  Response.Flush()
	  For i=0 to idb
	    Call ReadData(ida(i))
		If i=idb Then Response.Write("<p style='font-size:14px; color:#FF0000'><!--Star-->已经采集完所有数据<!--StarEnd--></p>")
	  Next
   Else
      Response.Write "本次共需要采集影片<span style='font-size:21px;font-weight:bold;color:#FF0000'>1</span>个 <a href='"&repage&"'>返回上一页</a>"
      Call ReadData(dataid)
   End If:Response.Write("</div>")

ElseIf Action="uppage" Then'采集所有
   Call ReadPage()
ElseIf Action="upday" Then '今日更新
   Call ReadDay()
ElseIf Action="search" Then '电影搜索
   Call ReadSearch()	
Else
   Call ReadList()
End If

Sub ReadPage()'处理分页采集
    Response.Write("<div style='font-size:12px'>")
	StaPage=QvodCms_CLng(Request.QueryString("stapage"))
	EndPage=QvodCms_CLng(Request.QueryString("endpage"))
	Classid=QvodCms_CLng(Request.QueryString("Classid"))
	If stapage<1 Then stapage=1:If EndPage<1 Then EndPage=1
	if cint(AdminId(21))>0 Then
	ListHtml=GetPage("http://www.dq521.com/qvodcms/qvodcms_list.asp?url="&ListUrl&"&page="&stapage&"&Classid="&Classid&"&pd="&qiangzi&"","gb2312")
	Else
	ListHtml=GetPage("http://www.dq521.com/qvodcms/qvodcms_list.asp?url="&ListUrl&"&page="&EndPage&"&Classid="&Classid&"&pd="&qiangzi&"","gb2312")
	End If
	ListHtml=GetContent(ListHtml,"<!--start -->","<!--end -->",0)
	ida=Split(ListHtml,"class=forumrow1>")
	idb=ubound(ida)
	Response.Write "正在采集第<span style='font-size:21px;font-weight:bold;color:#FF0000'>"&StaPage&"/"&EndPage&"</span>页 该页影片需要处理影片<span style='font-size:21px;font-weight:bold;color:#009900'>"&(idb)&"</span>个 <br>"
	Response.Flush()
	For jk=1 to idb
		i=jk-1
		Call ReadData(GetContent(ida(jk),"id=""",""" />",0))
		'Response.Write GetContent(ida(jk),"id=""",""" />",0)&"---------"&jk&"<BR>"
	Next
	Response.Write("</div>")
	If StaPage>=EndPage Then
        Response.Write("<p align='center' style='font-size:14px; color:#FF0000'>已经采集完所有数据！</p>")
    Else
		If cint(AdminId(21))>0 Then
        Response.Write("<p style='font-size:14px; color:#FF0000'>"&AdminId(21)&"秒后将自动采集下一页！</p><meta http-equiv='refresh' content="&AdminId(21)&";url='?Action=uppage&Url="&ListUrl&"&Endpage="&EndPage&"&StaPage="&StaPage+1&"&pd="&qiangzi&"&sj="&shuju&"&Classid="&Classid&"'>")
		Else
		Response.Write("<p style='font-size:14px; color:#FF0000'>"&AdminId(21)&"秒后将自动采集下一页！</p><meta http-equiv='refresh' content="&AdminId(21)&";url='?Action=uppage&Url="&ListUrl&"&Endpage="&EndPage-1&"&StaPage="&StaPage&"&pd="&qiangzi&"&sj="&shuju&"&Classid="&Classid&"'>")
		End If
    End If
End Sub

Sub ReadDay()'处理今日更新
	ListHtml=GetPage("http://www.qvodcms.com/qvodcms_cj/qvodzyday.asp?url="&ListUrl&"&qvodcmskey="&UserKey&"&Userweb="&Userweb&"","gb2312")
    Response.Write("<div style='font-size:12px'>")
    ida=split(ListHtml,",")
	idb=ubound(ida)
	If idb>0 Then
	Response.Write "本次共需要采集影片<span style='font-size:21px;font-weight:bold;color:#FF0000'>"&(idb+1)&"</span>个 <a href='"&repage&"'>返回上一页</a><br>"
	Else
	Response.Write "今日暂无影片更新 <a href='"&repage&"'>返回上一页</a><br>"
	End If
	Response.Flush()
	For i=0 to idb-1
		Call ReadData(ida(i))
		If i=idb-1 Then Response.Write("<p style='font-size:14px; color:#FF0000'>已经采集完所有数据！</p>")
	Next
	Response.Write("</div>")
End Sub

Sub ReadSearch()'处理搜索
	MaxPerPage=QvodCms_CLng(Request.QueryString("MaxPerPage"))
	Page=QvodCms_CLng(Request.QueryString("page"))
	ListHtml=GetPage("http://www.dq521.com/qvodcms/qvodcms_list.asp?action=search&keyword="&keyword&"&MaxPerPage="&MaxPerPage&"&page="&Page&"","gb2312")
    Response.Write("<div style='font-size:12px'>")
	ListHtml=Replace(ListHtml,"qvodcms_list.asp?","?action=search&")
	Response.Write(ListHtml)
	Response.Write("</div>")
End Sub

Sub ReadList()'获取分页列表源码
	Dim Classid,MaxPerPage,Page,ListHtml
	Classid=QvodCms_CLng(Request.QueryString("Classid"))
	MaxPerPage=QvodCms_CLng(Request.QueryString("MaxPerPage"))
	Page=QvodCms_CLng(Request.QueryString("page"))
	ListUrl="http://www.dq521.com/qvodcms/qvodcms_list.asp?Classid="&Classid&"&MaxPerPage="&MaxPerPage&"&page="&Page&""
	ListHtml=GetPage(ListUrl,"gb2312")
	ListHtml=Replace(ListHtml,"qvodcms_list.asp","")
	Response.Write(ListHtml)
End Sub

Sub ReadData(dataid)'获取单个数据源码
	On Error Resume Next
    Dim Html2
	Html2=GetPage("http://www.dq521.com/qvodcms/qvodcms_data.asp?id="&dataid&"&qvodcmskey="&UserKey&"&Userweb="&Userweb&"","gb2312")
	If  Instr(Html2,"查询错误qvodcms.Err") Then
		Response.Write("该片"&dataid&"已经过期或失效，服务器已将其删除，自动更新下一部..<br>")	
	Else
	    Response.Write DataHtml
		cj_class_id=GetContent(Html2,"<电影分类>","</电影分类>",0)
		cj_data_name=GetContent(Html2,"<电影名>","</电影名>",0)
		cj_data_reurl=GetContent(Html2,"<电影状态>","</电影状态>",0)
		cj_data_actor=GetContent(Html2,"<主演>","</主演>",0)
		cj_data_director=GetContent(Html2,"<导演>","</导演>",0)
		cj_data_intro=GetContent(Html2,"<内容简介>","</内容简介>",0)
		cj_data_intro=replace(cj_data_intro,vbcrlf,"")
		cj_data_picurl=GetContent(Html2,"<图片>","</图片>",0)
		cj_data_erea=GetContent(Html2,"<地区>","</地区>",0)
		cj_data_year=GetContent(Html2,"<年份>","</年份>",0)
		cj_data_language=GetContent(Html2,"<语言>","</语言>",0)
		cj_data_playurla=ReplaceCai(GetContent(Html2,"<影片地址>","</影片地址>",0))
		cj_data_time=Now()
		cj_data_playpath="快播QVOD"
		If cj_data_year="" Then cj_data_year=2011
		If cj_data_director="" then cj_data_director="未知"
		Dim CountNum:CountNum=ubound(split(cj_data_playurla,"<urll"))
		'If CountNum<1 then CountNum=1 Else CountNum=CountNum
		Response.Write("<br><span style='font-size:21px;font-weight:bold;color:#FF0000'>"&i+1&"</span> 影片名称:<font color=red>"&cj_data_name&"</font> 共有<font color='#FF0000'>"&CountNum&"</font>个播放地址<br>")	
		Response.flush() 
		cj_data_playurl=""
		For j=1 to CountNum
		   url=GetContent(split(cj_data_playurla,"<urll")(j),">","</urll>",0)
		   urlx=split(url,"$")
			 for aa=0 to ubound(urlx)
			 url=urlx(1)
			 next
		   cj_data_playurl=cj_data_playurl&"第"&j&"集$"&url&"#"
		Next
		If  Right(cj_data_playurl,1)="#" Then cj_data_playurl=Left(cj_data_playurl,Len(cj_data_playurl)-1) End IF
		'Response.Write cj_data_playurl
		'Response.End()
		Call ClassQvodCms
		Call InsertData()
		
	End If
End Sub

Sub ClassQvodCms()'处理影片分类
    Set Crs = Server.CreateObject("adodb.recordset")
    sql ="Select class_name,class_id from cj_class where class_name='"&cj_class_id&"'"
    Crs.Open sql, Conn_Cai, 1, 1
    If not(Crs.eof and Crs.bof) then
      class_id=Crs("class_id")
	Else
	  class_id=1
	End If  
    Crs.Close:set Crs=Nothing
End Sub
Conn_Cai.Close:Set Conn_Cai=Nothing:Call CloseConn()		  
%>
<div style="text-align:center; margin-top:5px; color: #FF0000">页面执行时间：<%=GetRunTime()%>秒</div>
</body></html>