Asp. NET to achieve HTTP way to get the function

Source: Internet
Author: User
Tags readline
asp.net <%@ Assembly name= "System.Net"%>
<%@ Import namespace= "System.Net"%>
<%@ Import namespace= "System.IO"%>
<script language= "VB" runat= "Server" >
Dim strtemp As String
Sub Page_Load (Src as Object, E as EventArgs)
Dim Httpwresp as HttpWebResponse
Dim SR as StreamReader
' Dim strtemp As String
Dim build As New StringBuilder

Httpwreq = Webrequestfactory.create ("http://www.funinspace.com")
Httpwreq.keepalive = False
Httpwresp = Httpwreq.getresponse ()
sr = new StreamReader (Httpwresp.getresponsestream (), ENCODING.ASCII)

Try
LINE=SR. ReadLine ()
Lineenc = Server. HTMLencode (line) & vbCrLf & "<br>"
Build.append (Lineenc)

Do in IsNothing (line)
line = Sr. ReadLine ()
Lineenc = Server. HTMLencode (line) & vbCrLf & "<br>"
Build.append (Lineenc)
Loop
Catch ex as Exception
Problem.text =ex. Message
End Try

Labelscrape.text=build. ToString ()
End Sub
</script>
<title>scraping A website</title>
<body bgcolor= "#FFFFFF" >
<asp:label id=problem runat= "Server"/>

<font face= "Courier New" size= "2" >
<asp:label id=labelscrape runat= "Server"/>
</font>
</body>

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.