<%Server.ScriptTimeOut=9999999
On Error Resume Next
%>
<form id="form1" name="form1" method="post" action="?operation=">
  <input type="submit" name="Submit" value="获取ID" />
  <input name="operation" type="hidden" id="operation" value="getID" />
  文件前半：
  <input name="file1" type="text" id="file1" value="http://127.0.0.1/hcno1/faq/admin/3/ShowClass(" size="60" />
  从
  <input name="from" type="text" id="from" value="1" size="5" />
  to 
  <input name="to" type="text" id="to" size="5" />
   文件后半
   <input name="file2" type="text" id="file2" value=").asp" size="12" />
   <br />
  <input name="s1" type="text" id="s1" value="&lt;div align=left&gt;&lt;A class=listA title=&quot;&quot; href=&quot;http://tech.haocai.com/ShowArticle.asp?ArticleID=" size="50" />
--  
<input name="s2" type="text" id="s2" value="&quot; target=_blank&gt;&lt;B&gt;" size="50" />
</form>
<p>
  <!-- #include file="conn.asp" -->
</p>
<p>&nbsp;</p>
<form id="form3" name="form3" method="post" action="">
  <label>
  <input type="submit" name="Submit3" value="写入内容" />
  </label>
  <label>
  classID
  <input name="classID" type="text" id="classID" size="5" />
  &nbsp;
  <input name="operation" type="hidden" id="operation" value="writeContent" />
  <br />
  &nbsp;文件前半：
  <input name="file1" type="text" id="file1" value="http://127.0.0.1/hcno1/faq/admin/2/ShowArticle(" size="60" />
  &nbsp;&nbsp;文件从
  <input name="from" type="text" id="from" value="1" size="5" />
  到
  <input name="to" type="text" id="to" size="5" />
  </label>
  
文件后半
   <input name="file2" type="text" id="file2" value=").asp" size="12" />
<p>
    <input name="s1" type="text" id="s1" value="&lt;h1 align=&quot;center&quot; class=&quot;PostName&quot;&gt;" size="50" />
    --  
    <input name="s2" type="text" id="s2" value="&lt;/h1&gt;" size="50" />
  </p>
  <p>
    <input name="s3" type="text" id="s3" value="&lt;td&gt;&lt;!--插入广告JS代码--&gt;&lt;/td&gt;" size="50" />
    --
    <input name="s4" type="text" id="s4" value="&lt;td class=Article_tdbgall align=right colSpan=2&gt;" size="50" />
</p>
  <p>
    <input name="s5" type="text" id="s5" value="&lt;td valign=&quot;bottom&quot;&gt; &lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;a href=&quot;" size="50" />
    --
    <input name="s6" type="text" id="s6" value="&quot;&gt;&lt;font color=&quot;#0066CC&quot;&gt;&lt;img src=&quot;" size="50" />
  </p>
</form>
<p>
  <%

'常用函数

'1、输入url目标网页地址，返回值getHTTPPage是目标网页的html代码
function getHTTPPage(url)
    dim Http
    set Http=server.createobject("MSXML2.XMLHTTP")
    Http.open "GET",url,false
    Http.send()
    if Http.readystate<>4 then 
        exit function
    end if
    getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
    set http=nothing
    if err.number<>0 then err.Clear 
end function

'2、转换乱玛，直接用xmlhttp调用有中文字符的网页得到的将是乱玛，可以通过adodb.stream组件进行转换
Function BytesToBstr(body,Cset)
        dim objstream
        set objstream = Server.CreateObject("adodb.stream")
        objstream.Type = 1
        objstream.Mode =3
        objstream.Open
        objstream.Write body
        objstream.Position = 0
        objstream.Type = 2
        objstream.Charset = Cset
        BytesToBstr = objstream.ReadText 
        objstream.Close
        set objstream = nothing
End Function

'截割
dim i22
i22=0
Function getID(str)
	
	if str<>"" then
'response.Write(request("s1"))
		arr=split(str,request("s1"))
		'response.Write(arr(1))
		if ubound(arr)>-1 then'不为空
			for jj=1 to ubound(arr)'不要第一个arr(0)
				if arr(jj)<>"" then
					arr1=split(arr(jj),request("s2"))
					id=arr1(0)
					i22=i22+1
					response.Write("<Br>*")
					response.Write("<a href=http://tech.haocai.com/ShowArticle.asp?ArticleID="&id&">"&i22&"</a>")
				end if
			next
		end if
	end if
end Function

function writeContent(str)

	if str<>"" then
	'response.write(str)
		'str=replace(str,chr(34),"")
		arr1=split(str,request("s1"))
		
		if ubound(arr1)>-1 then'不为空
			if arr1(1)<>"" then'不为空
					arr2=split(arr1(1),request("s2"))
					
					title=arr2(0)'标题
					title=replace(title,"<span class="&chr(34)&"S_headline2"&chr(34)&">","")
					title=replace(title,"<span class="&chr(34)&"S_headline1"&chr(34)&">","")
					title=replace(title,"</span>","")
'					title=replace(title,"<tr >","")
'					title=replace(title," ","")
'					title=replace(title,chr(13),"")
'					title=replace(title,chr(10),"")
					
					arr3=split(arr2(1),request("s3"))
					arr4=split(arr3(1),request("s4"))
					
					content=arr4(0)
				'	arr5=split(arr4(1),request("s5"))
'					arr6=split(arr5(1),request("s6"))
'					url2=arr6(0)
					content=replace(content,chr(13),"")
					content=replace(content,chr(10),"")
					content=replace(content,"<center></center></td></tr><tr>","")
					content=replace(content,"  ","")
					content=replace(content,"<div align=left>","")
					content=replace(content,"strong","b")
					'content=replace(content,"<center></center></td>","")
					'content=replace(content,"width=260 border=0 align=center cellpadding=1 cellspacing=1 bgcolor=#CCCCCC","")
					'response.Write(title&"<br>"&url2&"<br>"&content&"<Br>")
					'set rs=server.createobject("adodb.recordset")
'					rs.open "select * from down" ,conn,3,3
'					rs.addnew
'					rs("title")=title
'					rs("url")=url2
'					rs("content")=content
'					rs("classID")=19
'					rs.update
'					rs.close
'					set rs=nothing
					classID=request("classID")
					conn.execute("insert  into  FAQ(classID,title,re_content)   values   ("&classID&",'"&title&"','"&content&"')")
					i22=i22+1
					response.Write("<br>"&classID&"-"&i22&title)
			end if
		end if
	end if
end function

select case request.Form("operation")

case "getID"
	Dim Url,Html
	for ii=request("from") to request("to")
		Url=request("file1")&ii&request("file2")
		Html = getHTTPPage(Url)
		call getID(Html)
		'response.Write(url)
	next

case "writeContent"
	for iii=request("from") to request("to")
		Url=request("file1")&iii&request("file2")
		Html = getHTTPPage(Url)
		'response.Write("<br>"&iii&": ")
		call writeContent(Html)
		
	next
		

end select
'response.Write(Html)
%>


