I'm trying to see if a specific string exists in an html page but I can't seem to find an easy way to get the string that represents the body.
I've attempted:
http.request(Method.GET, { req ->
uri.path = '/x/app/main'
response.success = { resp, reader ->
assert resp.status == 200
println reader.text.startsWith('denied')
}
response.failure = { resp ->
fail("Failure reported: ${resp.statusLine}")
}
})
but reader.text is a NodeChildren object.
How do I get the html (or more specifically, the contexts of the body) as a string?
本文探讨了如何从HTML页面中提取Body部分的内容并将其转换为字符串形式。作者尝试使用HTTP请求来获取页面内容,但遇到了返回结果不是字符串而是NodeChildren对象的问题。
577

被折叠的 条评论
为什么被折叠?



