2015-04-03 17 views
1

我試圖找出是否存在特定的網頁。我在dart文件中使用dart:html庫,我對這些信息感興趣。找出是否存在特定的外部網站頁面(飛鏢)

例如,我想看看這樣的頁面存在:https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement.autofocus

我怎麼會在鏢這樣做呢?

+0

從在瀏覽器或服務器/命令行上運行達特代碼? – 2015-04-03 14:45:36

+0

@GünterZöchbauer在瀏覽器中 – 90intuition 2015-04-03 14:47:28

回答

2

只需獲取該網站,並且如果您收到錯誤響應,則該網站不存在(或當前已關閉)。

import 'dart:html'; 

main() async { 
    var url = 'http://www.google.com/somepage.html'; 
    var response = await HttpRequest.getString(url); 
    // examine response for errors 
} 

嘗試在DartPad