Asp.net 阿拉莫菲尔,请求后aspx页面
我对编程并不陌生,但我从未做过类似的事情,也不太擅长网络抓取 我正在尝试使用swift登录我的公司网站 HTML文件非常简单(从不更改),使用swiftSoup我可以解析它并修改登录和密码字段 在线阅读为了以编程方式登录,我应该发出post请求Asp.net 阿拉莫菲尔,请求后aspx页面,asp.net,swift,web-scraping,http-post,alamofire,Asp.net,Swift,Web Scraping,Http Post,Alamofire,我对编程并不陌生,但我从未做过类似的事情,也不太擅长网络抓取 我正在尝试使用swift登录我的公司网站 HTML文件非常简单(从不更改),使用swiftSoup我可以解析它并修改登录和密码字段 在线阅读为了以编程方式登录,我应该发出post请求 func logIn(){ let html = try! String(contentsOf: URL(string: "https://icrew.airmacau.com.mo/Login.aspx&q
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)
}
}
为了使用Alamofire发出此post请求以获取html文件,我应该如何处理
登录html页面有一个带有操作“login.aspx”的表单
这是我的尝试。。但老实说,我不确定应该向请求传递什么参数,以及是否需要向post请求传递其他参数
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)
}
}
一旦我在post请求中尝试了这段代码,我就会打印出与登录页面相同的html代码。。因此,我假设我传递密码和登录的方式是错误的
谢谢