发布到 url 时禁止 403

403 forbidden when posting to a url

我正在向网站发布请求:

request = (HttpWebRequest)WebRequest.Create("https://www.footlocker.dk/api/users/carts/current/entries?timestamp=1611595223668");

request.Method = "POST";

using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
  string json = "{\"user\":\"test\"," + "\"password\":\"bla\"}";

  streamWriter.Write(json);
}

var httpResponse = (HttpWebResponse)request.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
  {
    var result = streamReader.ReadToEnd();
  }

当我提交这个请求时,我收到了一个 403 forbidden,如下 html:

<html>
  <head>
    <title>footlocker.dk</title>
    <style>
      #cmsg{animation: A 1.5s;}@keyframes A{0%{opacity:0;}99%{opacity:0;}100%{opacity:1;}}
    </style>
  </head>
  <body style="margin:0">
    <p id="cmsg">Please enable JS and disable any ad blocker</p>
    <script>
      var dd={'cid':'AHrlqAAAAAMA2k9UvgFgVkIAk04eSQ==','hsh':'A55FBF4311ED6F1BF9911EB71931D5','t':'fe','r':'b','s':17434,'host':'geo.captcha-delivery.com'}</script><script src="https://ct.captcha-delivery.com/c.js">
   </script>
  </body>
</html>

有没有办法让浏览器认为 JS 已启用?

你为什么要提出这个要求?根据 Footlocker Terms of Service

You may not without the prior written permission of Foot Locker, use any computer code, data mining software, "robot", "bot", "spider", "scraper" or other automatic device, or program, algorithm or methodology having similar processes or functionality, or any manual process, to monitor or copy any of the web pages, data or content found on this Site or App, or accessed through this Site or App.

我假设您正试图在未经授权的情况下 scraping/monitoring 访问此网站,我强烈建议您停止,因为这违反了上述条款和条件。

也许尝试指定一个用户代理。