CopyCode The Code is as follows: <% @ Language = "VBScript" codePage = "936" %>
<! -- # Include file = "conn. asp" -->
<! -- # Include file = "INC/function. asp" -->
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en"
Http://www.w3.org/TR/html4/loose.dtd>
<HTML>
<Head>
<Title> untitled document </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Meta http-equiv = "refresh" content = "300; url = steal_house.asp">
</Head>
<Body>
<%
On Error resume next
'
Server. scripttimeout = 999999
'================================================ ========================
'Character encoding Functions
'================================================ ==================
Function bytestobstr (body, code)
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 = Code
Bytestobstr = objstream. readtext
Objstream. Close
Set objstream = nothing
End Function
'Position where the row string appears in another string
Function newstring (wstr, strng)
Newstring = instr (lcase (wstr), lcase (strng ))
If newstring <= 0 then newstring = Len (wstr)
End Function
'Replacement string Function
Function replacestr (ORI, str1, str2)
Replacestr = Replace (ORI, str1, str2)
End Function
'================================================ ==================
Function readxml (URL, code, start, ends)
Set osend = Createobject ("Microsoft. XMLHTTP ")
Sourcecode = osend. Open ("get", URL, false)
Osend. Send ()
Readxml = bytestobstr (osend. responsebody, code)
Start = instr (readxml, start)
Readxml = mid (readxml, start)
Ends = instr (readxml, ends)
Readxml = left (readxml, ends-1)
End Function
Function substr (body, start, ends)
Start = instr (body, start)
Substr = mid (body, start + Len (start) + 1)
Ends = instr (substr, ends)
Substr = left (substr, ends-1)
End Function
Dim getcont, newscontent
Dim URL, title
Url = "http: // www. ***. com" 'news URL
Getcont = readxml (URL, "gb2312", "<Table class = k2 border =" 0 "," </table> ")
Getcont = regexhtml (getcont)
Dim keyid, newsclass, city, position, housetype, level, area, price, demostra
Dim contactman, contact
For I = 2 to ubound (getcont)
Response. Write (getcont (I) & "__< br> ")
Templink = mid (getcont (I), instr (getcont (I), "href =" ") + 6, instr (getcont (I ),"""
Onclick ")-10)
Templink = Replace (templink ,"../","")
Response. Write (I & ":" & templink & "<br> ")
Newscontent = readxml (templink, "gb2312", "<TD valign =" "bottom ""
Width = "" 400 ">", "<HR width =" "760 ""
Noshade size = "" 1 "" color = "" #808080 "">
")
Newscontent = removehtml (newscontent)
Newscontent = Replace (newscontent, vbcrlf ,"")
Newscontent = Replace (newscontent, vbnewline ,"")
Newscontent = Replace (newscontent ,"","")
Newscontent = Replace (newscontent ,"","")
Newscontent = Replace (newscontent ,"","")
Newscontent = Replace (newscontent, "\ n ","")
Newscontent = Replace (newscontent, CHR (10 ),"")
Newscontent = Replace (newscontent, CHR (13 ),"")
'= Get content = =
Response. Write (newscontent)
Keyid = substr (newscontent, "column number:", "Information category :")
Newsclass = substr (newscontent, "category:", "City :")
City = substr (newscontent, "City:", "Location :")
Position = substr (newscontent, "Location:", "housing type :")
Housetype = substr (newscontent, "type:", "floor :")
Level = substr (newscontent, "floor:", "Use Area :")
Area = substr (newscontent, "Area:", "Price :")
Price = substr (newscontent, "Price:", "other instructions :")
Demostra = substr (newscontent, "NOTE:", "Contact :")
Contactman = substr (newscontent, "Contact:", "contact info :")
Contact = substr (newscontent, "contact information:", "Information Source :")
Response. Write ("total serial number:" & keyid & "<br> ")
Response. Write ("Information category:" & newsclass & "<br> ")
Response. Write ("City:" & City & "<br> ")
Response. Write ("Location:" & Position & "<br> ")
Response. Write ("house type:" & housetype & "<br> ")
Response. Write ("floor:" & level & "<br> ")
Response. Write ("area used:" & Area & "<br> ")
Response. Write ("Price:" & Price & "<br> ")
Response. Write ("other instructions:" & demostra & "<br> ")
Response. Write ("Contact:" & contactman & "<br> ")
Response. Write ("contact info:" & contact & "<br> ")
'Title = removehtml (AA (I ))
'Response. Write ("title:" & title)
For n = 0 to application. Contents. Count
If (application. Contents (n) = keyid) then
Ifexit = true
End if
Next
If not ifexit then
Application (Time & I) = keyid
'Add to database
'================================================ ==================
Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open "select top 1 * from news order by id desc", Conn, 3,3
Rs. addnew
RS ("newsclass") = newsclass
RS ("city") = City
RS ("position") = position
RS ("housetype") = housetype
RS ("level") = level
RS ("area") = Area
RS ("price") = Price
RS ("demostra") = demostra
RS ("contactman") = contactman
RS ("Contact") = Contact
Rs. Update
Rs. Close
Set rs = nothing
End if
'================================================ ==============
Next
Function removetag (Body)
Set RegEx = new Regexp
RegEx. pattern = "<[A]. *? <\/[A]>"
RegEx. ignorecase = true
RegEx. Global = true
Set matches = RegEx. Execute (Body)
Dim I, arr (15), ifexit
I = 0
J = 0
For each match in matches
Tempstr = match. Value
Tempstr = Replace (tempstr, "<TD> ","")
Tempstr = Replace (tempstr, "</TD> ","")
Tempstr = Replace (tempstr, "<tr> ","")
Tempstr = Replace (tempstr, "</tr> ","")
Arr (I) = tempstr
I = I + 1
If (I> = 15) then
Exit
End if
Next
Set RegEx = nothing
Set matches = nothing
Removetag = arr
End Function
Function regexhtml (Body)
Dim r_arr (47), r_temp
Set regex2 = new Regexp
Regex2.pattern = "<.*? <\/A>"
Regex2.ignorecase = true
Regex2.global = true
Set matches2 = regex2.execute (Body)
IIi = 0
For each match in matches2
R_arr (iii) = match. Value
IIi = III + 1
Next
Regexhtml = r_arr
Set regex2 = nothing
Set matches2 = nothing
End Function
'================================================ ====================
Conn. Close
Set conn = nothing
%>
</Body>
</Html>