ASP Crawl Page

Source: Internet
Author: User
Tags end regular expression trim
 
 
  1. <%
  2. If Trim (request.form ("url")) <> "Then
  3. Dim Vbody:vbody=getresstr (Trim (request.form ("url"))
  4. Dim res:res=vbody
  5. Dim Code:code=getcode (Vbody, "charset= {0,}" ([^]+) {0,} "")
  6. End If
  7. %>
  8. Crawl Page
  9. Please enter%20name= "Type=text value=" <%=trim (Request.Form ("P >>< URL?)" %>? Size= "Url?>"
  10. Page encoding:<%=code%>
  11. <%=res%>
  12. <%
  13. function Getresstr (URL)
  14. Dim Resbody,resstr,pagecode
  15. Set http=server.createobject ("msxml2.serverxmlhttp.3.0")
  16. Http.settimeouts 10000, 10000, 10000, 10000
  17. Http.open "Get", Url,false
  18. Http.send ()
  19. If http.readystate =4 Then
  20. If http.status=200 Then
  21. Resstr=http.responsetext
  22. Resbody=http.responsebody
  23. Pagecode=replace (GetCode (Resstr, "charset= ([^\" "].*" ""), Chr (10), "" "
  24. Getresstr=bytestobstr (Http.responsebody,trim (Pagecode))
  25. End If
  26. End If
  27. End Function
  28. ' Function name: bytestobstr
  29. ' Function: Convert binary data to characters
  30. ' Parameters: body-binary data, cset-text encoding method
  31. Function Bytestobstr (Body,cset)
  32. Dim objstream
  33. Set objstream = Server.CreateObject ("ADODB.stream")
  34. Objstream. Type = 1
  35. Objstream. Mode =3
  36. Objstream. Open
  37. Objstream. Write body
  38. Objstream. Position = 0
  39. Objstream. Type = 2
  40. Objstream. Charset = Cset
  41. Bytestobstr = objstream. ReadText
  42. Objstream. Close
  43. Set objstream = Nothing
  44. End Function
  45. ' Function name: GetCode
  46. ' function: Convert binary to character
  47. ' Parameters: str-to query string, regstr-regular expression
  48. Function GetCode (STR,REGSTR)
  49. Dim Reg
  50. Set reg= new REGEXP
  51. Reg.ignorecase = True
  52. Reg.multiline = True
  53. Reg.pattern =regstr
  54. Set Cols = Reg.execute (str)
  55. Str=cols (0). Submatches (0)
  56. Getcode=str
  57. End Function
  58. %>
This article links http://www.cxybl.com/html/wlbc/Asp/20120613/29966.html

Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.