First of all, it depends on what operating system you're using.

On Windows

If you right click and press "save" (Alternatively use ctrl-s) and then chose the file format "json" when saving.

On macOS

You can do this in a few ways, I'd suggest using curl. You'd do this by opening the terminal and navigating to the directory you'd like to download the file to. Then enter the following:

curl https://somedomain.com/somepath.json > fileName.json

This will download the file in its original format.

Answer from Maximilian on Stack Overflow
🌐
Reddit
reddit.com › r/data › good easy way to download json from the web?
r/data on Reddit: Good easy way to download JSON from the web?
July 20, 2022 -

So I've got a JSON file I want to download from a website.

The data comes in a URL that ends with a 6 digit ID number (unfortunately I cannot find a logic to the ID but it's not a single increment system, so I'd like to be able to check like the next 10,000 ID's say once a week).

I'd then like to pull parts of the JSON files into some kind of spreadsheet (dumping to a CSV is fine). There is a lot of data I don't need/want in these files. I know how to pull the data into excel but I feel like there will be a better way to do this automagically.

🌐
CodeSandbox
codesandbox.io › s › download-json-file-with-js-p9t1z
download json file with Js - CodeSandbox
January 30, 2020 - download json file with Js by hieuht2048
Published   May 20, 2019
Author   hieuht2048
🌐
n8n
community.n8n.io › questions
Download image from Url(s) in a Json File - Questions - n8n Community
August 26, 2022 - I am new here and have problems to read all URL’s from a JSON file. You can find my workflow here. Maybe there is someone who can help me? I create a HTTP request to the JSON file. In another request I say that I want to get the “coverImgUrl” as a file, so I can read it as a URL and copy ...
🌐
GitHub
gist.github.com › petermeissner › c15f178711266405528ed751cf0cb5fb
Download JSON file from webpage · GitHub
Clone via HTTPS Clone using the web URL. ... Clone this repository at <script src="https://gist.github.com/petermeissner/c15f178711266405528ed751cf0cb5fb.js"></script> Save petermeissner/c15f178711266405528ed751cf0cb5fb to your computer and use it in GitHub Desktop. ... This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below.
🌐
JMP User Community
community.jmp.com › t5 › Discussions › How-to-parse-a-JSON-file-opened-from-URL › td-p › 44791
Solved: How to parse a JSON file opened from URL? - JMP User Community
September 28, 2017 - I would like to import a JSON file into JMP that is downloaded off of the web. The best way I've been able to do this is through the GUI, manually selecting File --> Open --> and entering the URL into "File Name".
🌐
ASPSnippets
aspsnippets.com › Articles › 3990 › Download-JSON-File-from-URL-in-C-and-VBNet
Download JSON File from URL in C and VBNet
December 18, 2024 - webClient.DownloadFile("https://raw.githubusercontent.com/aspsnippets/test/master/Customers.json", @"D:\Files\Customers.json"); ... webClient.DownloadFile("https://raw.githubusercontent.com/aspsnippets/test/master/Customers.json", ...
🌐
Jameslmilner
jameslmilner.com › posts › downloading-a-file-with-javascript
Downloading Text, JSON and Images with clientside JavaScript
January 8, 2023 - // Turn the JSON object into a string const data = "Hello world"; // Pass the string to a Blob and turn it // into an ObjectURL const blob = new Blob([data], { type: "text/plain" }); const jsonObjectUrl = URL.createObjectURL(blob); // Create an anchor element, set it's // href to be the Object URL we have created // and set the download property to be the file name // we want to set const filename = "example.txt"; const anchorEl = document.createElement("a"); anchorEl.href = jsonObjectUrl; anchorEl.download = filename; // There is no need to actually attach the DOM // element but we do need to click on it anchor.click(); // We don't want to keep a reference to the file // any longer so we release it manually URL.revokeObjectURL(jsonObjectUrl);
Find elsewhere
🌐
Valentino G.
valentinog.com › blog › link-download
JSON files download with the anchor download attribute
April 5, 2020 - What instead if we want to generate a JSON file on the fly and let the user download it? Data URL to the rescue! A Data URL is composed of four parts: ... // omit for brevity function buildJSON(form) { const data = new FormData(form); const entries = data.entries(); const obj = Object.fromEntries(entries); const json = JSON.stringify(obj); const dataURL = `data:application/json,${json}`; }
🌐
MyCleverAI
mycleverai.com › it-questions › how-can-i-download-a-json-file-from-a-link
How can I download a JSON file from a link?
import requests import json url = "https://example.com/data.json" response = requests.get(url) if response.status_code == 200: data = response.json() with open("data.json", "w") as f: json.dump(data, f, indent=2) print("JSON file downloaded successfully!") else: print(f"Failed to download, ...
🌐
UiPath Community
forum.uipath.com › help
Downloading JSON from Web and getting data to datable - Help - UiPath Community Forum
July 14, 2018 - Hi, I need to get JSON file from http address from web. Address returns JSON file. In file is a list of companys names and addresses. After that i need to get names to datable. I have no idea how to accomplish this, co…
🌐
GitHub
gist.github.com › ganezasan › 4fbdfff0bf828eca3c74
Download JSON File · GitHub
Clone via HTTPS Clone using the web URL. ... Clone this repository at <script src="https://gist.github.com/ganezasan/4fbdfff0bf828eca3c74.js"></script> Save ganezasan/4fbdfff0bf828eca3c74 to your computer and use it in GitHub Desktop. ... This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below.
🌐
Reddit
reddit.com › r/learnpython › trouble downloading json files from a url
r/learnpython on Reddit: Trouble downloading JSON files from a URL
April 19, 2022 -

I'm trying to download JSON files from a URL. When I've attempted to open the saved JSON files in python, I get the error:

"raise JSONDecodeError("Expecting value", s, err.value) from None".

Whenever I try opening the JSON files in a URL, I see this:

"SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data"

Below is a simplified version of my code. Is there a way to download JSON files correctly?

def read_url(url):

    urls = []
    psfiles = []
    
    url = url.replace(" ","%20")
    req = Request(url)
    a = urlopen(req).read()
    soup = BeautifulSoup(a, 'html.parser')
    x = (soup.find_all('a'))
    for i in x:
        file_name = i.extract().get_text()
        url_new = url + file_name
        url_new = url_new.replace(" ","%20")
        if(file_name[-1]=='/' and file_name[0]!='.'):
            read_url(url_new)
        if url_new.endswith('json'):
            urls.append(url_new)
      
    for i in urls:
        psfile = i.replace('url','')
        psfiles.append(psfile)
 
         
    for j in range(len(psfiles)):
        urllib.request.urlretrieve("url", "path to directory"+psfiles[j])


if __name__ == '__main__':
    while True:
        read_url("url")
        time.sleep(1800)
Top answer
1 of 2
5
here's a code snippet with requests that works >>> import requests >>> >>> url = 'https://old.reddit.com/r/learnpython/comments/v02hmv/trouble_downloading_json_files_from_a_url.json' >>> >>> response = requests.get(url) >>> json_data = response.json() >>> print(json_data) some of the output: [{'kind': 'Listing', 'data': {'after': None, 'dist': 1, 'modhash': '', 'geo_filter': '', 'children': [{'kind': 't3', 'data': {'approved_at_utc': None, 'subreddit': 'learnpython', 'selftext': 'I\'m trying to download JSON files from a URL. When I\'ve attempted to open the saved JSON files in python, I get the error:\n\n"raise JSONDecodeError("Expecting value", s, err.value) from None".\n\nWhenever I try opening the JSON files in a URL, I see this:\n\n"SyntaxError: JSON.parse: [...] if that doesn't work at your URL it's probably not valid a json string in the response you're getting
2 of 2
2
Imho you should start by actively debugging the stages in your code. The prime place to start is to check what is actually downloaded, eg add html = urlopen(req).read() # avoid confusing names like 'a' with open("base.html", "w") as fp: fp.write(html) to check in an editor or browser if that's a functional webpage that includes your data. Then add prints to the data extracted in BS, so links = (soup.find_all('a')) # again, more useful name print("found", len(links), "urls") for link in links: # you see now it reads more like English than 'for i in x' file_name = link.extract().get_text() print("file_name", file_name) url_new = url + file_name url_new = url_new.replace(" ","%20") if(file_name[-1]=='/' and file_name[0]!='.'): print("calling read_url with", url_new) read_url(url_new) else: print("skipping read_url") # or whatever you would call this case if url_new.endswith('json'): print("appending", url_new) urls.append(url_new) else: print("not json", url_new) same for the rest. Then you can actually know what parts are working and if it behaves like you're expecting.
🌐
Mozilla Discourse
discourse.mozilla.org › t › download-a-json-from-personnal-website › 12158
Download a .json from personnal website - addons.mozilla.org - Mozilla Discourse
November 22, 2016 - Hello ! 🙂 Some days ago, I submited an add-on named “Drive+” to review, the version I submited use a .json file included in the package. At the time i submited the add-on I didn’t knew how the whole verification system worked, so now I know, I’m thinking about making the file external.
🌐
ParseHub
parsehub.com › blog › scrape-data-json
How to Scrape data from any website to a JSON file | ParseHub
June 1, 2021 - Better yet, ParseHub can run on a schedule and update your JSON file with new data every hour or day or week. It all depends on your project needs. ... For today’s example, we will run a very simple scrape of Amazon’s result page for the term “computer monitor”. Make sure to download and install ParseHub for free before we get started. Open ParseHub, click on “New Project” and enter the URL ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1852759 › downloading-json-file-using-invoke-webrequest-by-p
Downloading JSON file using Invoke-WebRequest by passing credentials and SessionToken - Microsoft Q&A
I am trying to download a JSON file from a URL which requires UserName, Password, User ID and SessionToken. I am referring an article: https://support.tidepool.org/hc/en-us/articles/360029368992-Downloading-your-Tidepool-Web-Notes PS…