asp.net - Alamofire,发布请求 aspx 页面
问题描述
我对编程并不陌生,但我从来没有做过类似的事情,也不是网络抓取方面的专家。
我正在尝试使用 swift 登录我的公司网站。
https://icrew.airmacau.com.mo/Login.aspx
HTML 文件非常简单(从不更改),使用 swiftSoup 我可以解析它并修改登录和密码字段。
在线阅读以便以编程方式登录我应该发出一个帖子请求。
为了使用 Alamofire 发出此帖子请求以取回 html 文件,我应该如何进行?
登录 html 页面有一个带有“Login.aspx”操作的表单
这是我的尝试.. 但老实说,我不确定我应该将什么参数传递给请求,以及是否需要将其他参数传递给发布请求。
func logIn(){
let html = try! String(contentsOf: URL(string: "https://icrew.airmacau.com.mo/Login.aspx")!)
let doc: Document = try! SwiftSoup.parse(html)
print("***************")
let username : Element = try! doc.getElementById("userName")!
print(username)
let pass : Element = try! doc.getElementById("userPassword")!
print(pass)
try! username.append("1234")
try! pass.append("aassbbcc")
//
let parameter = ["userName":"1234",
"userPassword":"aassbbcc"]
// POST request ....in order to login
AF.request ("https://icrew.airmacau.com.mo/Login.aspx",method: .post, parameters: parameter).responseString { response in
print("\(response.result)")
print(response)
}
}
一旦我通过发布请求尝试此代码,我就会打印出与登录页面相同的 html 代码。所以我假设我传递密码和登录的方式是错误的。
谢谢
解决方案
推荐阅读
- oracle - 有什么方法可以在字典表中找到所有内置的 oracle 函数?
- javascript - 将 easylist 与 chrome declarativeNetRequest 一起使用
- python - 我发起了一个回调,但它没有按定义工作
- python - 如何卸载 python 3.6 版并保留 3.7 版 OSX
- bash - 这个使用 grep 的 bash 脚本看起来正确吗?
- xamarin.forms - 水印和选定项填充
- c# - 如何立即将实时音频流发送到 IBM Watson Speech-To-Text,而不使用 C# 和 IBM Watson SDK 在本地保存音频文件?
- jupyter-notebook - 不加空行可以合并单元格吗
- java - 如何通过 Android Studio 中的 WebView 实现 Google 地图
- unity3d - 点击按钮时手机上的图形故障