简体   繁体   English

如何从URL以字符串形式下载网页

[英]How to download webpage from url as string

I'm trying to download JSON from a URL as a string, like a DownloadString() method in C#. 我正在尝试从URL作为字符串下载JSON,就像C#中的DownloadString()方法一样。

I'm not sure how to do it. 我不确定该怎么做。 I need something like that: 我需要这样的东西:

var abc=DownloadString("url");
var myBooks = JSON.parse(abc); 

It's my first day with JS and jQuery. 这是我使用JS和jQuery的第一天。 I'm sorry if this question is stupid, but i need to solve it fastly 很抱歉,这个问题很愚蠢,但我需要尽快解决

Use Fetch : 使用提取

async function getBooks() {
    var abc = await fetch("file.json");
    var myBooks = await abc.json()
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM