我在httpwebresponse中收到错误404,这是我每次输入新的URL时都会使用循环从URL的json提取数据的行为,
所以我的循环就像这个textbox6.text每次给出+1值时都可以说我以550开始,它继续为551552553,以此类推,如果我到达一个带有URL的数字而没有响应,程序确实给出440错误(崩溃)我想发表该声明
Dim response As HttpWebResponse = request.GetResponse()
使其成为IF声明,如果网站未响应,则应该执行textbox6.text = textbox6.text +1否则它什么都不做
Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
Dim uristring As String = ("https://api.themoviedb.org/3/movie/" + TextBox6.Text + "?api_key=315b4646c080bc576529769498ccc658")
Dim uri As New Uri(uristring)
Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
request.Method = "get"
Dim response As HttpWebResponse = request.GetResponse()
Dim read = New StreamReader(response.GetResponseStream)
Dim rawresp As String = read.ReadToEnd()
Dim jsonResulttodict = JsonConvert.DeserializeObject(Of Dictionary(Of String, Object))(rawresp)
Dim imdb_ID = jsonResulttodict.Item("imdb_id")
TextBox3.Text = imdb_ID
End Sub