且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用HTTP请求编码字符串以进行发送?

更新时间:2022-01-20 06:45:37

我假设你URL的末尾的散列(#)实际上是查询参数的一部分。问题是Node.js将其视为整个URL的哈希值,它在HTTP请求中不起作用。因此,您需要正确编码查询字符串。

I'm assuming that the hash (#) at the end of your URL is actually part of the query argument. The problem is that Node.js is treating it as the hash of your overall URL, which plays no role in HTTP requests. Thus, you'll need to properly encode the query string.

结构化API函数,如 querystring.stringify 可能是***的。

A structured API function like querystring.stringify is probably best.

var query = querystring.stringify({
  key: '"https://me.yahoo.com/a/xt4hQ7QYssA8hymJKv8MeVQQKGhq_1jwvas-#a6e6f"'
});