-
-
Notifications
You must be signed in to change notification settings - Fork 184
Open
Description
The information I get on the page is always the source code, I can't get the rendered page code.
How can I get the page after the dynamic rendering is complete, just like checking it in Chrome?
And my code like this:
fun main(args: Array<String>) {
val client = WebClient(BrowserVersion.CHROME).apply {
options.apply {
isCssEnabled = true
isJavaScriptEnabled = true
isThrowExceptionOnScriptError = false
isRedirectEnabled = true
isActiveXNative = true
}
javaScriptEngine = CustomJsEngine(this)
ajaxController = NicelyResynchronizingAjaxController()
waitForBackgroundJavaScript(10 * 1000)
}
Damai.start(client)
client.close()
}
object Damai {
/**
* 打开买票界面
* @param client 浏览器实例
*/
fun start(client: WebClient) {
val scanner = Scanner(System.`in`)
// val url = scanner.next()
val url = "https://detail.damai.cn/item.htm?spm=a2oeg.home.card_0.ditem_1.591b23e1KA3wRj&id=601539289783"
println("大麦网购票地址:")
val homePage = client.getPage<HtmlPage>(url)
// println(homePage.asText())
val loginBtn = homePage.getFirstByXPath<HtmlSpan>(
"//div[@class='dm-header-wrap']//div[@class='dm-header-box']//div[@class='right-header']" +
"//div[@class='box-header user-header']//div[@class='login-user show']" +
"//span[@class='span-box-header span-user']")
startLogin(loginBtn.click())
}
/**
* 进行登陆
* @param page 点击后的登陆界面
*/
private fun startLogin(page: HtmlPage) {
val loginDiv = page.getHtmlElementById<HtmlDivision>("alibaba-login-iframe")
println(loginDiv.asXml())
}
}
zwy20034751
Metadata
Metadata
Assignees
Labels
No labels