VB.net HttpWebRequest 403错误
我的代码是100%工作,但当我尝试填写yelp.com下的表格时,它给我403错误。这是我的密码:VB.net HttpWebRequest 403错误,vb.net,httpwebrequest,http-status-code-403,Vb.net,Httpwebrequest,Http Status Code 403,我的代码是100%工作,但当我尝试填写yelp.com下的表格时,它给我403错误。这是我的密码: Dim cweb As String = "http://www.yelp.com/biz_share?bizid=T6XCD1_eLEk3LaSp8C7E1g&return_url=%2Fbiz%2Fmr-c-los-angeles-2" Dim POST As String = "csrftok=6cc5dea3ff8bf8f404f1e7a4951342cb2
Dim cweb As String = "http://www.yelp.com/biz_share?bizid=T6XCD1_eLEk3LaSp8C7E1g&return_url=%2Fbiz%2Fmr-c-los-angeles-2"
Dim POST As String = "csrftok=6cc5dea3ff8bf8f404f1e7a4951342cb2f132a17cb625a3988c50027d358285d&context=pyZQEaHS1YbhP3EEsTKGww&action_submit=1&emails=samplemail@gmail.com&emails=&emails=&unauth_name=Test+Name&unauth_email=testemail%40email.com¬e=How%27s+it+going%3F"
Dim request As HttpWebRequest
Dim response As HttpWebResponse
Dim tempCookies As New CookieContainer
request = CType(WebRequest.Create(cweb), HttpWebRequest)
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0"
request.AllowAutoRedirect = True
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = POST.Length
request.Method = "POST"
request.KeepAlive = True
request.CookieContainer = tempCookies
Dim requestStream As Stream = request.GetRequestStream()
Dim postBytes As Byte() = Encoding.ASCII.GetBytes(POST)
requestStream.Write(postBytes, 0, postBytes.Length)
requestStream.Close()
response = CType(request.GetResponse(), HttpWebResponse)
tempCookies.Add(response.Cookies)
Dim postreader As New StreamReader(response.GetResponseStream())
Dim thepage As String = postreader.ReadToEnd
response.Close()
我基于的web表单如下所示:
http://www.yelp.com/biz_share?bizid=T6XCD1_eLEk3LaSp8C7E1g&return_url=%2Fbiz%2Fmr-c-los-angeles-2
在其他网络表单上,我可以填写并发送它们,这是否意味着yelp.com不允许您发送任何网络请求?我现在真的很困惑。任何帮助都将乐意接受,提前感谢。csrftok将针对每个用户/会话进行更改,403存在,因为您的身份验证数据不正确/csrftok对会话无效。您需要转到此之前的页面(或登录页面或类似页面)以获取正确的令牌。鉴于403是一个禁止的错误,我假设Yelp正在阻止来自未经身份验证的地址的post请求。是否有任何方法可以绕过此阻止?除非您能够在Yelp通过服务器身份验证。至少,没有合法的途径。最好从yelp.com开始——见一节。我不知道他们是否允许远程发布内容,但那将是开始搜索的最佳地点。我将通过该链接进行探索。谢谢,我希望我能找到一些有用的东西。