README.md

December 4, 2022 ยท View on GitHub

Upload / Download code using System.Net.WebClient Class, POST DATA, or download HTML webpages etc

Description

This code can send data to a webpage using the HTTP POST method, or download an HTML webpage and return a string response value in both cases.

More Info

Submitted On
ByJon Barker
LevelIntermediate
User Rating3.7 (11 globes from 3 users)
CompatibilityVB.NET
CategoryInternet/ Browsers/ HTML
World.Net (C#, VB.net)
Archive File

Source Code

====== < PUT RIGHT AT TOP OF MODULE
Imports System
Imports System.text
======= < PUT RIGHT AT TOP OF MODULE
Function DownloadPage(ByVal sCompleteURL As String) As String
  Dim wDownload As System.Net.WebClient = New System.Net.WebClient()
  Dim bHTML As Byte() = wDownload.DownloadData(sCompleteURL)
  Dim sWebPage As String = Encoding.ASCII.GetChars(bHTML)
  Return sWebpage
 End Function
Function PostData(ByVal sAddress As String, ByVal sData As String) As String
  Dim wUpload As Net.WebClient = New System.Net.WebClient()
  Dim bPostArray As Byte() = Encoding.ASCII.GetBytes(sData)
  Dim bResponse As Byte() = wUpload.UploadData(sAddress, "POST", bPostArray)
  Dim sWebPage As String = Encoding.ASCII.GetChars(bResponse)
  Return sWebPage
 End Function