Get the specified area content code in ASP

Source: Internet
Author: User
Tags trim

<form name= "Form1" method= "Post" action= "" >
<textarea name= "AA" rows= "5" id= "AA" ></textarea>
<textarea name= "BB" rows= "5" id= "BB" ></textarea>
<input type= "Submit" name= "Submission" value= "submitted" >
</form>
<%
'================================================
' Function name: Findmatch
' function: Interception of matched content
' Return value: After the intercepted string
'================================================
Public Function Findmatch (ByVal str, ByVal Start, ByVal last)
Dim match
Dim s
Dim filterstr
Dim matchstr
Dim strcontent
Dim Arrayfilter ()
Dim i, N
Dim brepeat

If Len (start) = 0 or Len (last) = 0 Then Exit function

On Error Resume Next

Matchstr = "(" & Correctpattern (Start) & ") (. +?) ("& Correctpattern (last) &") "

Dim re
Set re = new RegExp
Re.ignorecase = True
Re.global = True
Re.pattern = Matchstr
Set S = Re.execute (str)
n = 0
For the match in S
If n = 0 Then
n = n + 1
ReDim Arrayfilter (N)
Arrayfilter (n) = match
Else
Brepeat = False
For i = 0 To UBound (arrayfilter)
If UCase (match) = UCase (Arrayfilter (i)) then
Brepeat = True
Exit For
End If
Next
If Brepeat = False Then
n = n + 1
ReDim Preserve Arrayfilter (N)
Arrayfilter (n) = match
End If
End If
Next

Set S = Nothing
Set re = Nothing

Strcontent = Join (arrayfilter, "| | |")
Strcontent = replace (strcontent, Start, "")
Strcontent = replace (strcontent, Last, "")

Findmatch = replace (strcontent, "| | |", vbNullString, 1, 1)
Exit function
End Function


Private Function Correctpattern (ByVal str)
str = replace (str, "", "")
str = replace (str, "~", "~")
str = replace (str, "!", "!")
str = replace (str, "@", "@")
str = replace (str, "#", "#")
str = replace (str, "%", "%")
str = replace (str, "^", "^")
str = replace (str, "&", "&")
str = replace (str, "*", "*")
str = replace (str, "(", "(")
str = replace (str, ")", ")")
str = replace (str, "-", "-")
str = replace (str, "+", "+")
str = replace (str, "[", "[")
str = replace (str, "]", "]")
str = replace (str, "<", "<")
str = replace (str, ">", ">")
str = replace (str, ".", ".")
str = replace (str, "/", "/")
str = replace (str, "?", "?")
str = replace (str, "=", "=")
str = replace (str, "|", "|")
str = replace (str, "$", "$")
Correctpattern = str
End Function

'================================================
' Function name: gethttppage
' Function: Get HTTP page
' parameter: URL----remote URL
' Return value: Remote HTML code
'================================================
Public Function Getremotedata (ByVal URL)
Cset = "gb2312"
Dim Strheader
Dim l

On Error Resume Next

Dim retrieval
Dim objstream
Set objstream = CreateObject ("ADODB.stream")
objStream.Type = 1
Objstream.mode = 3
objStream.Open
Set retrieval = CreateObject ("Msxml2.xmlhttp")
With retrieval
. Open ' get ', url, False
. setRequestHeader "referer", url
. Send
If. readystate <> 4 Then Exit function
If. Status > Then Exit function
'--Get the target Web file header
Strheader =. getResponseHeader ("Content-type")
Strheader = UCase (Strheader)
Objstream.write (. Responsebody)
End With
Set retrieval = Nothing

If Len (Strheader) > 0 Then
'--Get target file encoding
L = InStrRev (Strheader, "charset=",-1, 1)
If l > 0 Then
Cset = Right (Strheader, Len (strheader)-l-7)
Else
Cset = Cset
End If
End If

objstream.position = 0
objStream.Type = 2
Objstream.charset = Trim (CSET)
Getremotedata = Objstream.readtext
objStream.Close
Set objstream = Nothing
Exit function
End Function
%>
<%
Fromurl = "Http://www.111cn.net"

AA = Trim (Request.Form ("AA"))
bb = Trim (Request.Form ("BB"))
If aa<> "" and bb<> "" Then Response.Write Findmatch (Getremotedata (Fromurl), AA,BB)
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.