gpt4 book ai didi

javascript - 如何在 webview 中显示或只读来自网站的表单? - swift

转载 作者:行者123 更新时间:2023-11-28 08:36:53 24 4
gpt4 key购买 nike

任何专家都可以告诉我如何在我的UIWebView 中只显示该网站的登录表单吗? ?

http://webgiz.faqserv.com/webgiz/

(这是一个截图,以防我的链接不可用):

enter image description here

如果我不能,我如何使用 Swift 用我的变量填写这个表格?

现在我使用下面的缓解代码:WV1.stringByEvaluatingJavaScriptFromString("document.getElementById('username')‌​.value = '" + RA + "'") WV1.stringByEvaluatingJavaScriptFromString("document.getElementById('passwd').v‌​alue = '" + CPF + "'") WV1.stringByEvaluatingJavaScriptFromString("document.getElementById('btnlogin')‌​.click()")

最佳答案

您必须检测其余的完整参数才能登录此 joomla 门户:

例如:

POST 方法: http://webgiz.faqserv.com/webgiz/index.php?option=com_aixgen&username=test&password=test&userType=A&instituicao=0

@IBOutlet weak var usernameTextField: UITextField!
// `passwordTextField.secureTextEntry = true`
@IBOutlet weak var passwordTextField: UITextField!
@IBOutlet weak var webView: UIWebView!

...

@IBAction func signIn(sender: AnyObject) {
var url = NSURL(string: "http://webgiz.faqserv.com/webgiz/index.php")
var request = NSMutableURLRequest(URL: url!)
request.HTTPMethod = "POST"

// Get the user's credentials from the `UITextField`s
var username: String = usernameTextField.text
var password: String = passwordTextField.text

// Concatenating everything together
var userCredentials: String = "username=\(username)&passwd=\(password)&userType=A&instituicao=0" // add all parameters needed
var bodyData: String = "\(userCredentials)"

// Encode the bodyData string into a
request.HTTPBody = bodyData.dataUsingEncoding(NSUTF8StringEncoding)

// load the UIWebView `webView` with this request
webView.loadRequest(request)
}

关于javascript - 如何在 webview 中显示或只读来自网站的表单? - swift ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37486805/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com