2016-07-21 32 views
1

我想使用以下代碼在此URL上使用UrlFetchApp.Fetch獲取HTML元素。但是,似乎只有某些URL可以工作。其他網址只返回500或錯誤的請求。從Google應用程序腳本中獲取UrlFetchApp.Fetch()的響應並在記錄器上打印

function getHTML() 
    { 
     var response = UrlFetchApp.fetch("http://www.theoutlet24.com/th/catalogsearch/\ 
             result/index/?cat=0&limit=all&q=4X4Man"); 
     Logger.log(response); 
    } 

在這個問題上的任何幫助是可觀的。

+0

你使用應用腳本? –

回答

1

僅添加{muteHttpExceptions:true}作爲URL.I已經測試其工作!

function getHTML() 
    { 
    var response = UrlFetchApp.fetch("http://www.theoutlet24.com/th/catalogsearch/result/index/?cat=0&limit=all&q=4X4Man",{muteHttpExceptions:true}); 
    Logger.log(response); 
    } 
相關問題