我試圖用對的HtmlUnit加載的Playstation Store頁面,但看起來像它加載與「正在加載...」文本(和一些JavaScript)空白頁的一切。 我用下面的配置,使工作的HtmlUnit,但絕望(其科特林):阻止HtmlUnit加載PSN商店頁面?
мая 09, 2017 4:08:22 PM com.gargoylesoftware.htmlunit.html.HtmlScript isExecutionNeeded
WARNING: Script is not JavaScript (type: application/json, language:). Skipping execution.
мая 09, 2017 4:08:22 PM com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController processSynchron
INFO: Re-synchronized call to https://sonynetworkentertainment.112.2o7.net/b/ss/snestorewebloadglobal/1/chidv1/s75296982536092?AQB=1&ndh=1&t=9%2F5%2F2017%2016%3A8%3A22%202%20-180&ts=1494335302&vid=c61f4752-adfd-84d1-728c-187350f9aa37&pageName=web%3Aloading_start&v1=D%3DpageName&g=https%3A%2F%2Fstore.playstation.com%2F&r=&v2=xx-xx&ch=web%3Aloading_start&c68=D%3Dg&c72=web&v72=web&cc=USD&ce=UTF-8&server=web&events=event1&AQE=1
мая 09, 2017 4:08:22 PM com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController processSynchron
INFO: Re-synchronized call to https://store.playstation.com/kamaji/api/chihiro/00_09_000/geo
的問題是:什麼停止
@Test
@Throws(Exception::class)
fun homePage() {
val webClient = WebClient(BrowserVersion.INTERNET_EXPLORER).apply {
ajaxController = NicelyResynchronizingAjaxController()
options.isUseInsecureSSL = true
options.isThrowExceptionOnScriptError = false
options.isJavaScriptEnabled = true
options.isCssEnabled = true
options.isRedirectEnabled = true
options.isThrowExceptionOnFailingStatusCode = false
options.isUseInsecureSSL = true
options.isDownloadImages = true
cookieManager.isCookiesEnabled = true
waitForBackgroundJavaScript(10000)
waitForBackgroundJavaScriptStartingBefore(10000)
}
val page = webClient.getPage<HtmlPage>("https://store.playstation.com/")
Thread.sleep(10000)
assertFalse(page.asXml().contains("Loading"))
}
我不加載頁面時看到任何具體的錯誤HtmlUnit從加載頁面?我試圖自己弄明白,但我唯一的想法是,它可能是針對無頭瀏覽器的某種防禦或HtmlUnit不支持的非常重的JS。但對於例如
可以沒有任何麻煩地打開。
謝謝你,我知道這是SPA。但是HtmlUnit可以處理JS請求,它實際上可以在一些SPA中工作。看起來我已經用錯了方式等待JS執行 – Ilya