1

我的代码 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=6cc5dea3ff8bf8f404f1e7a4951342cb2f132a17cb625a3988c50027d358285d&context=pyZQEaHS1YbhP3EEsTKGww&action_submit=1&emails=samplemail@gmail.com&emails=&emails=&unauth_name=Test+Name&unauth_email=testemail%40email.com&note=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()

我基于的网络表单是这样的:

http://www.yelp.com/biz_share?bizid=T6XCD1_eLEk3LaSp8C7E1g&return_url=%2Fbiz%2Fmr-c-los-angeles-2

在其他网络表单上,我可以填写并发送它们,这是否意味着 yelp.com 不会让您发送任何网络请求?我现在真的很困惑。任何帮助都将很高兴地接受提前感谢。

4

1 回答 1

0

csrftok 将为每个用户/会话更改,403 在那里是因为您的身份验证数据错误/csrftok 对会话无效。您需要转到此之前的页面(或登录页面或类似页面)以获取正确的令牌。

于 2013-11-16T22:40:03.380 回答