Frequently Used functions when making ASP thieves.
Collection page:
Function getpage (URL)
Dim senddata, Retrieval
Set retrieval = Createobject ("Microsoft. XMLHTTP ")
With Retrieval
. Open "Post", URL, false
. SetRequestHeader "Content-Type", "application/X-WWW-form-urlencoded"
. SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0;. Net CLR 1.1.4322 )"
. Send ()
Getpage = bytestobstr (. responsebody)
End
Set retrieval = nothing
End Function
Conversion garbled characters:
Function bytestobstr (Body)
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 = "gb2312"
Bytestobstr = objstream. readtext
Objstream. Close
Set objstream = nothing
End Function
Obtains the specified content.
Function getcontent (STR, start, last, n)
If instr (lcase (STR), lcase (start)> 0 then
Select case n
Case 0' truncates left and right (both take the front) (place keyword)
Getcontent = right (STR, Len (STR)-instr (lcase (STR), lcase (start)-len (start) + 1)
Getcontent = left (getcontent, instr (lcase (getcontent), lcase (last)-1)
Case 1 'intercept both the left and right (both take the front) (retain the keyword)
Getcontent = right (STR, Len (STR)-instr (lcase (STR), lcase (start) + 1)
Getcontent = left (getcontent, instr (lcase (getcontent), lcase (last) + Len (last)-1)
Case 2 'only truncate to the right (take the previous one) (remove the keyword)
Getcontent = right (STR, Len (STR)-instr (lcase (STR), lcase (start)-len (start) + 1)
End select
Else
Getcontent = ""
End if
End Function
Delete HTML tags:
Function delhtml (htmlcode)
Dim istart, iend
Dim stemp
Stemp = htmlcode
Istart = instr (stemp, "<")
Iend = instr (stemp, "> ")
Do While istart> 0 and iend> 0 and iend-istart> 0
Stemp = Replace (stemp, mid (stemp, istart, iend-istart + 1 ),"")
Istart = instr (stemp, "<")
Iend = instr (stemp, "> ")
Loop
Delhtml = stemp
End Function