Google应用脚本的urlfetch编码网址 [英] Google apps script urlfetch encoding URL

查看:100
本文介绍了Google应用脚本的urlfetch编码网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用urlfetch填充页面数据的电子表格,但我尝试使用的URL会返回一个错误作为无效参数。我认为问题在于我在URL中使用了被误解的字符(例如,引号和括号)。

I would like to use urlfetch to populate a spreadsheet with page data but the URL that I am trying to use is coming back with an error as an invalid argument. I think the problem is that I am using characters in the URL that are being misinterpreted (e.g. quotation marks and parentheses).

我尝试使用命令对URL进行编码下面,但我假设我是双重编码的一些字符,这是导致问题。

I have tried to encode the URL with the command below but I am assuming that I am double encoding some of the characters and that is causing a problem.

var encodedURL = encodeURIComponent(pageURL)


推荐答案

尝试使用 b

Try using

baseURL + encodeURIComponent(parameterString)

将传递给正在查询的基本URL的参数包含在哪里作为传递给encodeURIComponent函数的值。这篇文章可能对你有用:

Where you include the parameters you're passing to the base URL you are querying as the value passed to the encodeURIComponent function. This post may be of use to you:

Encode URL in JavaScript?

如果您编码整个URL,就像您在上面做的那样,您就是编码不仅仅是参数,我认为这就是你的问题所在。

If you encode the entire URL, like it looks like you are doing above, you're encoding more than just the parameters, which I assume would be where your problem lies.

这篇关于Google应用脚本的urlfetch编码网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆