Results 1 to 2 of 2

Thread: code ใช้โหลด html มาเลยครับ ไม่ต้องเข้า web แล้ว click ขวา

  1. #1
    Junior Member
    Join Date
    Jun 2008
    Posts
    2


    Private m_strRemoteHost As String 'the web server to connect to
    Private m_strFilePath As String 'relative path to the file to retrieve
    Private m_strHttpResponse As String 'the server response
    Private m_bResponseReceived As Boolean
    '
    Private Sub cmdReadURL_Click()
    '
    Dim strURL As String 'temporary buffer
    '
    On Error GoTo ERROR_HANDLER
    '
    'check the textbox
    If Len(txtURL) = 0 Then
    MsgBox "Please, enter the URL to retrieve.", vbInformation
    Exit Sub
    End If
    '
    'if the user has entered "http://", remove this substring
    '
    If Left(txtURL, 7) = "http://" Then
    strURL = Mid(txtURL, 8)
    Else
    strURL = txtURL
    End If
    '
    'get remote host name
    '
    m_strRemoteHost = Left$(strURL, InStr(1, strURL, "/") - 1)
    '
    'get relative path to the file to retrieve
    '
    m_strFilePath = Mid$(strURL, InStr(1, strURL, "/"))
    '
    'clear the RichTextBox
    '
    rtbDocument.Text = ""
    '
    'clear the buffer
    '
    m_strHttpResponse = ""
    '
    'turn off the m_bResponseReceived flag
    '
    m_bResponseReceived = False
    '
    'establish the connection
    '
    With wscHttp
    .Close
    .LocalPort = 0
    .Connect m_strRemoteHost, 80
    End With
    '
    EXIT_LABEL:
    Exit Sub

    ERROR_HANDLER:
    '
    If Err.Number = 5 Then
    strURL = strURL & "/"
    Resume 0
    Else
    MsgBox "Error was occurred." & vbCrLf & _
    "Error #: " & Err.Number & vbCrLf & _
    "Description: " & Err.Description, vbExclamation
    GoTo EXIT_LABEL
    End If
    '
    End Sub

    Private Sub Form_Load()

    End Sub

    Private Sub wscHttp_Close()
    '
    Dim strHttpResponseHeader As String
    '
    'to cut of the header info, we must find
    'a blank line (vbCrLf & vbCrLf)
    'that separates the message body from the header
    '
    If Not m_bResponseReceived Then
    strHttpResponseHeader = Left$(m_strHttpResponse, _
    InStr(1, m_strHttpResponse, _
    vbCrLf & vbCrLf) - 1)
    Debug.Print strHttpResponseHeader
    m_strHttpResponse = Mid(m_strHttpResponse, _
    InStr(1, m_strHttpResponse, _
    vbCrLf & vbCrLf) + 4)
    '
    'pass the document data to the RichTextBox control
    '
    rtbDocument.Text = m_strHttpResponse
    '
    'turn on the m_bResponseReceived flag
    '
    m_bResponseReceived = True
    '
    End If
    '
    End Sub

    Private Sub wscHttp_Connect()
    '
    Dim strHttpRequest As String
    '
    'create the HTTP Request
    '
    'build request line that contains the HTTP method,
    'path to the file to retrieve,
    'and HTTP version info. Each line of the request
    'must be completed by the vbCrLf
    strHttpRequest = "GET " & m_strFilePath & " HTTP/1.1" & vbCrLf
    '
    'add HTTP headers to the request
    '
    'add required header - "Host", that contains the remote host name
    '
    strHttpRequest = strHttpRequest & "Host: " & m_strRemoteHost & vbCrLf
    '
    'add the "Connection" header to force the server to close the connection
    '
    strHttpRequest = strHttpRequest & "Connection: close" & vbCrLf
    '
    'add optional header "Accept"
    '
    strHttpRequest = strHttpRequest & "Accept: */*" & vbCrLf
    '
    'add other optional headers
    '
    &#39;strHttpRequest = strHttpRequest & <Header Name> & _
    <Header Value> & vbCrLf
    &#39;. . .
    &#39;
    &#39;add a blank line that indicates the end of the request
    strHttpRequest = strHttpRequest & vbCrLf
    &#39;
    &#39;send the request
    wscHttp.SendData strHttpRequest
    &#39;
    Debug.Print strHttpRequest
    &#39;
    End Sub

    Private Sub wscHttp_DataArrival(ByVal bytesTotal As Long)
    &#39;
    On Error Resume Next
    &#39;
    Dim strData As String
    &#39;
    &#39;get arrived data from winsock buffer
    &#39;
    wscHttp.GetData strData
    &#39;
    &#39;store the data in the m_strHttpResponse variable
    m_strHttpResponse = m_strHttpResponse & strData
    &#39;
    End Sub



  2. #2
    Junior Member
    Join Date
    Sep 2008
    Posts
    16


    ขอบคุณมากน่ะครับ
    คือผมลองไปเปิดที่ผมเคยเขียนเอาไว้ ยังไงได้ผลเหมือนหรือต่างกันยังไง ช่วยชี้แนะให้ด้วยน่ะครับ

    **Hidden Content: To see this hidden content your post count must be 10 or greater.**


    เปลี่ยน http://www.google.com เป็น url ที่เราต้องการดู code น่ะครับ
    หากมี MSGbox ขึ้นมาว่า OK ก็แสดงว่ามีการตอบสนอง โปรแกรมจะเซฟโค้ดไว้ให้เราที่ C:\testbyNineEx.txt หรือหากเราต้องการเซฟเป็นไฟล์ html ก็ลองเปลี่ยนเป็น testbyNineEx.html หรือเปลี่ยนชื่อดูตามความต้องการดูน่ะครับ

Similar Threads

  1. Yahoo, Click Forensics To Battle Click Fraud Together
    By newsbot in forum World Hacking/Security News
    Replies: 0
    Last Post: 20-03-2008, 08:16 PM
  2. Replies: 4
    Last Post: 20-03-2008, 05:24 PM
  3. Replies: 2
    Last Post: 16-10-2007, 10:29 AM
  4. Click to Convert v6.0 ( PDF OR HTML )
    By HarO in forum Window Application
    Replies: 0
    Last Post: 13-10-2007, 03:20 AM
  5. Code หา image จาก code html มาฝาก
    By sut in forum PHP,ASP,Javascript, Html
    Replies: 1
    Last Post: 02-06-2007, 07:10 PM

Members who have read this thread : 0

Actions : (View-Readers)

There are no names to display.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •