我正在尝试从网站下载图片,但它给了我错误,即(远程服务器返回错误:(502)Bad Gateway)。我在互联网上搜索了很多,但没有得到确切的解决方案。此代码正在某些网站上运行,但在少数网站上显示上述错误。 请检查下面的代码......
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim filename As String = Application.StartupPath
If Not filename.EndsWith("\") Then filename &= "\"
txtLocalFile.Text = "D:\a.jpg" 'filename & " "
txtRemoteFile.Text = "http://bseworld.bseindia.com/eventgallery/cricket2015/19Feb2015/2.jpg"
End Sub
Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownload.Click
Application.DoEvents()
Try
Dim web_client As WebClient = New WebClient
Dim wp = New WebProxy("proxy ip", proxy_port)
wp.Credentials = New NetworkCredential("uname", "password", "domainname")
web_client.Proxy = wp
web_client.DownloadFile(txtRemoteFile.Text, txtLocalFile.Text)
MessageBox.Show("Done")
Catch ex As Exception
End Try
End Sub
您能否告诉我哪部分代码丢失或者我必须更改..
答案 0 :(得分:0)
我做了一些RND,最后我的代码正在运行。
CommandError: need exactly two arguments for username and password