我試圖請求一個網站的html代碼,並將其用於Xcode(Swift 3.0)和pod Alamofire中的應用程序。在線的HTML代碼中,我想要抓取的數據內容是在div類中,它以javascript web插件的形式從Events日曆返回數據。由於該網站不是靜態的,當我請求html並以字符串的形式輸出結果時,我想要的數據不包含在字符串中。出現一則消息,說:使用alamofire + swift獲取動態加載的html使用alamofire + swift
<noscript>Your browser must support JavaScript to view this content. Please enable JavaScript in your browser settings then try again. <a href="https://www.trumba.com">Events calendar powered by Trumba</a> </noscript>
我使用Alamofire代碼如下所示:
func downloadCalendar(){
Alamofire.request(urlString).responseString { (AlamofireResponse) in
print(AlamofireResponse.result.value!)
}
}
的urlString是實際網頁的網址變量。 有沒有一種方法可以使用Alamofire將在線html中顯示的所有html導入到Xcode中?如果Alamofire無法實現,那麼還有另一種使用Swift的方法嗎?