dart - 如何使用 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
解决方案
302 表示重定向 - <a href="https://en.wikipedia.org/wiki/HTTP_302" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/HTTP_302
查看location
响应中的标头并执行另一个请求!
推荐阅读
- django - django send_mail 指向 http://dpaste.com/ 的链接不安全
- express - 禁止用户时删除快速会话
- grep - 如何使用 findstr 或 grep 命令在文本文件中查找指定长度的字符串?
- python - 如何在 Python 项目中正确构建内部脚本?
- javascript - 我在反应中使用 scrollLeft 但它没有将它的值设置为元素
- javascript - “$” - 谁先拥有它?jQuery 或浏览器
- r - 如何使用条件表达式的 r 数据名来过滤数据的数据帧?
- ios - 移除 CoreGraphics 动画
- reactjs - 当我在 create-react-app 中输入 npm start 时如何指定自定义 URL
- python - 如何根据世代显示,x '攻击' 和 y '防御'