Results 1 to 2 of 2

Thread: download/upload to websites using WebClient

  1. #1

    Thread Starter
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    download/upload to websites using WebClient

    Ok, a few people have asked about sending data to a website like a browser (simulating the <form> in html pages)

    here's an example form on a website
    Code:
    <form method="post" action="http://themis.**********.com/cgi-bin/search.cgi">
      	<select name="D1" size="1">
    		<option value="subject">Article Content</option>
    		<option value="name">Author name</option>
    		<option value="eseek">Web Search</option>
    	</select>&nbsp; 	<input type="text" name="term" size="12">
                       <input name="search" type="image" src="images/go.gif" alt="Search Now!" align="middle" border="0">
    </form>
    so the fields you need to send are "D1", "term" and probably not needed for this site but for HTML standards sake also "search" (the button pressed)

    NOTE: when value is set in the <option> tag within <select> tag this is what you send.

    we send a fieldname/value object where we set these fields, the response will be in byte form, we need to convert it to ASCII to read it

    Code:
            Dim wc As New Net.WebClient 'the webclient
            Dim bt() As Byte 'the returned bytes
            Dim html As String 'the returned HTML text
    
            'setup fields to be sent
            Dim fields As New Specialized.NameValueCollection
            fields.Add("D1", "subject") 'search option
            fields.Add("term", "test") 'search box
            fields.Add("search", "") 'button pressed
    
            bt = wc.UploadValues("http://themis.**********.com/cgi-bin/search.cgi", fields) 'send fields and retrieve response
            html = System.Text.Encoding.ASCII.GetString(bt) 'convert to text
    
            MsgBox(html)
    this example sends the search "test" to the webpage and returns the results in HTML
    Last edited by Phill64; Dec 17th, 2007 at 03:43 PM.

  2. #2
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Re: download/upload to websites using WebClient

    is this work with php?

Posting Permissions

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



Click Here to Expand Forum to Full Width