我正在尝试模仿此Java代码:
try {
Connection.Response programacion1 = Jsoup.connect(URLProg1)
.cookies(cookies)
.data(formData2)
.method(Connection.Method.POST)
.userAgent(USER_AGENT)
.execute();
Document programacion= programacion1.parse();
Elements table = programacion.select("table").tagName("datos"); //select the table.
Elements rows = table.select("tr");
FileWriter programacionTexto = null;
PrintWriter pw1 = null;
使用AlamoFire 5使用此Alamofire快速代码:
AF.request(URLProg1, method: .post, parameters: parametersProgramcion, encoding: URLEncoding.httpBody).responseString
{ (response3) in
let value = response3.value
let json = JSON(response3.value)
let table = json["datos"]
let rows = table["tr"]
}
女巫,我不知道它对最终目标是否正确。但是,这是我运行应用程序时的主要问题,我可以调试print(在需要时)HTML输出,但是响应请求为nil(参见图片),因此json也是0,依此类推,因此,我无法使用数据。就像它不解析一样。你能帮我吗?
顺便说一句,我也确实使用过responseJSON,但我也遇到了同样的问题,也就是“ 0附近没有字符”问题。
找到它。由于响应是HTML,因此我使用swiftSoup进行了解析和使用。谢谢大家,我没有注意到我没有得到JSON对象作为响应。