UrlFetchApp在url中具有特殊字符

时间:2012-06-28 01:31:02

标签: google-apps-script

我的剧本:

var Url = 'http://readonline.egscans.com/Remnant/Chapter_036_[END]';
var response = UrlFetchApp.fetch(Url).getContentText();

运行脚本时出现此错误。

  

“参数无效:http://readonline.egscans.com/Remnant/Chapter_036_[END]

1 个答案:

答案 0 :(得分:3)

您可以使用encodeURIComponent对URL进行编码,如下所示:

var Url = encodeURIComponent('http://readonline.egscans.com/Remnant/Chapter_036_[END]');

参考:https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURIComponent