Httpwebrequest System.UriFormatException:'无效的URI:URI方案无效。'错误

时间:2019-02-22 12:07:07

标签: .net vb.net

我有使用httpwebrequest的示例代码,但Httpwebrequest行之一具有

返回System.UriFormatException:'无效的URI:URI方案无效。'错误。

我不明白为什么会返回错误。

任何人都会给我小费,谢谢!

Dim postData As String = ""
Dim logincookie
Dim tempcookies As New CookieContainer
Dim encoding As New UTF8Encoding
Dim byteData As Byte() = encoding.GetBytes(postData)
Dim postreq As HttpWebRequest = DirectCast(HttpWebRequest.Create("https://blog.naver.com/bikeshin?Redirect=Log&logNo=221466829247"), HttpWebRequest)
postreq.Method = "GET"
postreq.KeepAlive = True
postreq.CookieContainer = tempcookies
postreq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729"
postreq.ContentType = "application/x-www-form-urlencoded"
postreq.Referer = "https://search.naver.com/search.naver?where=post&sm=tab_jum&query=%EC%98%81%ED%99%94"
Dim postresponse As HttpWebResponse
postresponse = DirectCast(postreq.GetResponse, HttpWebResponse)
tempcookies.Add(postresponse.Cookies)
logincookie = tempcookies
Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
Dim thepage As String = postreqreader.ReadToEnd
WebBrowser1.DocumentText = thepage

Dim urladdress As String = "https//blog.naver.com/PostView.nhn?blogId=bikeshin&logNo=221466829247&from=search&redirect=Log&widgetTypeCall=true&topReferer=https://search.naver.com/search.naver?where=post&sm=tab_jum&query=%EC%98%81%ED%99%94&directAccess=false"
postreq = DirectCast(HttpWebRequest.Create(urladdress), HttpWebRequest)   ' <== in here have return error
postreq.Method = "GET"
postreq.KeepAlive = True
postreq.CookieContainer = tempcookies
postreq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729"
postreq.ContentType = "application/x-www-form-urlencoded"
postreq.Referer = "https://search.naver.com/search.naver?where=post&sm=tab_jum&query=%EC%98%81%ED%99%94"

postresponse = DirectCast(postreq.GetResponse, HttpWebResponse)
tempcookies.Add(postresponse.Cookies)
logincookie = tempcookies
'Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
thepage = postreqreader.ReadToEnd

0 个答案:

没有答案