首页 > 解决方案 > 如何使用 Dart 抓取带有登录页面的网站?

问题描述

我想登录一个网站,但是我不能,而且我是 Dart 的新手。我尝试运行此代码:

var url = "https://example.com/login";
  http.post(url, body: {"login": "xxxxx", "password": "xxxx"})
      .then((response) {
    print("Response status: ${response.statusCode}");
    print("Response body: ${response.body}");

之后我收到发布请求:

Response status: 302
Response body: //empty

标签: dart

解决方案


302 表示重定向 - <a href="https://en.wikipedia.org/wiki/HTTP_302" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/HTTP_302

查看location响应中的标头并执行另一个请求!


推荐阅读