全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2017
推到 Plurk!
推到 Facebook!

請教各位先進~~運用ASP.NET or VB.NET程式擷取網頁原始碼

尚未結案
Lazy
一般會員


發表:2
回覆:1
積分:0
註冊:2005-05-14

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-06-07 21:44:02 IP:220.130.xxx.xxx 未訂閱
as the title.. 只要能擷取網頁source code至記事本即可~ 我曾在貴討論區下載過""azurecloud""大大發表的程式下載過擷取中時電子報... 小弟嘗試修改... 但卻屢試不成... 請各位先進相助... 感激!! 或者函式庫有函式可運用??
qoo1234
版主


發表:256
回覆:1167
積分:659
註冊:2003-02-24

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-06-08 00:33:25 IP:220.131.xxx.xxx 未訂閱
C# http://www.ccs.neu.edu/teaching/webservices/TestHTTP/ViewHTMLPane_cs.htm 自行轉VB.NET  
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.IO
Imports System.Net
Namespace TestHTTP            Public Class ViewHTMLPane
        Inherits System.Windows.Forms.Form
                Private Get_URI As System.Windows.Forms.Button
                Private URI_Box As System.Windows.Forms.TextBox
                Private HTML_Box As System.Windows.Forms.RichTextBox
                Private components As System.ComponentModel.Container = Nothing                    Public Sub New()
                        InitializeComponent
                End Sub                    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
                        If disposing Then
                                If Not (components Is Nothing) Then
                                        components.Dispose
                                End If
                        End If
                        MyBase.Dispose(disposing)
                End Sub                    Private Sub InitializeComponent()
                        Me.HTML_Box = New System.Windows.Forms.RichTextBox
                        Me.URI_Box = New System.Windows.Forms.TextBox
                        Me.Get_URI = New System.Windows.Forms.Button
                        Me.SuspendLayout
                        Me.HTML_Box.DetectUrls = False
                        Me.HTML_Box.Font = New System.Drawing.Font("Courier New", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType((0), System.Byte))
                        Me.HTML_Box.Location = New System.Drawing.Point(20, 70)
                        Me.HTML_Box.Name = "HTML_Box"
                        Me.HTML_Box.ReadOnly = True
                        Me.HTML_Box.Size = New System.Drawing.Size(750, 480)
                        Me.HTML_Box.TabIndex = 3
                        Me.HTML_Box.Text = ""
                        Me.URI_Box.Font = New System.Drawing.Font("Courier New", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType((0), System.Byte))
                        Me.URI_Box.Location = New System.Drawing.Point(120, 20)
                        Me.URI_Box.Name = "URI_Box"
                        Me.URI_Box.Size = New System.Drawing.Size(650, 23)
                        Me.URI_Box.TabIndex = 1
                        Me.URI_Box.Text = ""
                        Me.Get_URI.Font = New System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType((0), System.Byte))
                        Me.Get_URI.Location = New System.Drawing.Point(20, 20)
                        Me.Get_URI.Name = "Get_URI"
                        Me.Get_URI.Size = New System.Drawing.Size(80, 23)
                        Me.Get_URI.TabIndex = 2
                        Me.Get_URI.Text = "Get URI"
                        AddHandler Me.Get_URI.Click, AddressOf Me.Get_URI_Click
                        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 15)
                        Me.ClientSize = New System.Drawing.Size(792, 573)
                        Me.Controls.Add(Me.HTML_Box)
                        Me.Controls.Add(Me.Get_URI)
                        Me.Controls.Add(Me.URI_Box)
                        Me.Name = "ViewHTMLPane"
                        Me.Text = "ViewHTML"
                        Me.ResumeLayout(False)
                End Sub                     _
                Shared Sub Main()
                        Application.Run(New ViewHTMLPane)
                End Sub                    Private Sub Get_URI_Click(ByVal sender As Object, ByVal e As System.EventArgs)
                        Get_URI_HTML(URI_Box.Text)
                End Sub                    Private Sub Get_URI_HTML(ByVal uri As String)
                        HTML_Box.Clear
                        Dim request As WebRequest = Nothing
                        Dim response As WebResponse = Nothing
                        Dim reader As StreamReader = Nothing
                        Try
                                request = WebRequest.Create(uri)
                                response = request.GetResponse
                                reader = New StreamReader(response.GetResponseStream)
                                HTML_Box.Text = reader.ReadToEnd
                        Catch ex As Exception
                                HTML_Box.Text  = ex.Message
                        Finally
                                If Not (reader Is Nothing) Then
                                        reader.Close
                                End If
                                If Not (response Is Nothing) Then
                                        response.Close
                                End If
                        End Try
                End Sub
        End Class 
End Namespace     
網海無涯,唯學是岸!
系統時間:2024-05-21 21:13:04
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!