Use the requests module: import requests r = requests.get(https://api.fda.gov/drug/label.json) https://requests.readthedocs.io/en/master/user/quickstart/ The website you linked also has API documentation, check it out. Answer from the_shell_man_ on reddit.com
Discussions

Downloading JSON file through Python - Stack Overflow
I have a link that gives me a "save as" dialog box for a .pst file every time I run it. I want to try to save the file to a 'sample.txt' file without opening it since the size is 500 MB. Is there... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How can I download multiple .json files in one go from a site?
Hi all, I am using chatbase.co https://www.chatbase.co/ where I am hosting several chatbots. For each chatbot it is possible to download a .json file specified by a date interval which stores the chat conversation. Right now I have to go in manually and download each .json conversation one by one. More on discuss.python.org
๐ŸŒ discuss.python.org
0
0
August 12, 2023
How to download the json content using python - Stack Overflow
import requests import json response ... as file: file.write(response.content) f = 'pakka.txt' records = [json.loads(line) for line in open(f)] records[0] Hi guys - This code worked for me. Thanks for all the suggestions. ... import urllib.request resource = urllib.request.urlopen('https://raw.githubusercontent.com/wesm/pydata-book/2nd-edition/datasets/bitly_usagov/example.txt') content = resource.read().decode(resource.headers.get_content_charset()) ... import requests import json # docs.python.org/3/lib... More on stackoverflow.com
๐ŸŒ stackoverflow.com
October 12, 2018
Generate (and download) JSON file from hosted site using server side python
I then want to return the json file to the client side python app. As mentioned, I have never needed to do this before so I am not sure of the correct/best way to do it, or if wordpress will even interface with python in this way. Solutions that I have thought of so far, include: - 1) Interface ... More on codeforum.org
๐ŸŒ codeforum.org
2
0
July 16, 2022
๐ŸŒ
Real Python
realpython.com โ€บ python-json
Working With JSON Data in Python โ€“ Real Python
August 20, 2025 - If you followed along with the tutorial, then youโ€™ve got a hello_frieda.json file that doesnโ€™t contain newlines or indentation. Alternatively, you can download hello_frieda.json in the materials by clicking the link below: Free Bonus: Click here to download the free sample code that shows you how to work with JSON data in Python.
๐ŸŒ
GitHub
github.com โ€บ justinbalaguer โ€บ python-json-url-download
GitHub - justinbalaguer/python-json-url-download: python script for downloading files from json data url
python script for downloading files from json data url - justinbalaguer/python-json-url-download
Author ย  justinbalaguer
๐ŸŒ
AEANET
aeanet.org โ€บ home โ€บ how to download a json file?
How to Download a JSON File? - AEANET
November 8, 2025 - This command downloads the file and saves it as filename.json. Command-Line (Wget): bash wget <JSON_FILE_URL> -O filename.json This command performs a similar function as the cURL command above. APIs often provide data in JSON format. Accessing these APIs usually involves sending HTTP requests ...
๐ŸŒ
Python.org
discuss.python.org โ€บ python help
How can I download multiple .json files in one go from a site? - Python Help - Discussions on Python.org
August 12, 2023 - Hi all, I am using chatbase.co https://www.chatbase.co/ where I am hosting several chatbots. For each chatbot it is possible to download a .json file specified by a date interval which stores the chat conversation. Rigโ€ฆ
Find elsewhere
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 52781589 โ€บ how-to-download-the-json-content-using-python
How to download the json content using python - Stack Overflow
October 12, 2018 - import requests import json response = requests.get('https://raw.githubusercontent.com/wesm/pydata-book/2nd-edition/datasets/bitly_usagov/example.txt') with open('pakka.txt', mode = 'wb') as file: file.write(response.content) f = 'pakka.txt' records = [json.loads(line) for line in open(f)] records[0] Hi guys - This code worked for me. Thanks for all the suggestions. ... import urllib.request resource = urllib.request.urlopen('https://raw.githubusercontent.com/wesm/pydata-book/2nd-edition/datasets/bitly_usagov/example.txt') content = resource.read().decode(resource.headers.get_content_charset()) ... import requests import json # docs.python.org/3/library/urllib.request.html#examples r = requests.get('raw.githubusercontent.com/wesm/pydata-book/2nd-edition/datasets/โ€ฆ) print(r) 2018-10-12T15:27:11.2Z+00:00
๐ŸŒ
Code Forum
codeforum.org โ€บ software & web development โ€บ back-end development โ€บ python
Python - Generate (and download) JSON file from hosted site using server side python | Code Forum - Where your coding journey begins
July 16, 2022 - https://my_domain.com/my_folder/my_file.json From a python app running locally, I want to download the json file, but before the file is downloaded, I want to run a server side python script that will extract the latest information from a mysql database to update the json file.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ reading-and-writing-json-to-a-file-in-python
Reading and Writing JSON to a File in Python - GeeksforGeeks
The JSON package in Python has a function called json.dumps() that helps in converting a dictionary to a JSON object. It takes two parameters: dictionary: the name of a dictionary which should be converted to a JSON object. indent: defines the number of units for indentation ยท After converting the dictionary to a JSON object, simply write it to a file using the "write" function.
Published ย  August 5, 2025
๐ŸŒ
CodeRivers
coderivers.org โ€บ blog โ€บ python-loading-json-file
Python Loading JSON Files: A Comprehensive Guide - CodeRivers
April 5, 2025 - The json module is a built-in module in Python that provides functions for working with JSON data. To use it, you first need to import it: ... To read a JSON file in Python, you can use the following steps: 1. Open the file in read mode.
๐ŸŒ
Salem State Vault
www-backup.salemstate.edu โ€บ home โ€บ finces โ€บ effortless guide: how to download json file quickly today
Effortless Guide: How to Download JSON File Quickly Today - Salem State Vault
May 29, 2025 - Using a command-line tool: If you're ... you can use tools like `curl` or `wget` to download JSON files. Using a programming language: If you're a developer, you can use a programming language like Python or JavaScript to download JSON files programmatically...
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ trouble downloading json files from a url
r/learnpython on Reddit: Trouble downloading JSON files from a URL
April 8, 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.
๐ŸŒ
Power CMS Technology
powercms.in โ€บ article โ€บ how-get-json-data-remote-url-python-script
How to get json data from remote url into Python script | Power CMS Technology
August 17, 2016 - import urllib, json url = "http://maps.googleapis.com/maps/api/geocode/json?address=googleplex&sensor=false" response = urllib.urlopen(url) data = json.loads(response.read()) print data ... check out JSON decoder in the requests library.
๐ŸŒ
Medium
medium.com โ€บ @ryan_forrester_ โ€บ save-and-load-json-files-in-python-a-complete-guide-49a5760b8b49
Save and Load JSON Files in Python: A Complete Guide | by ryan | Medium
October 28, 2024 - JSON files are everywhere โ€” from web APIs to configuration files. Letโ€™s explore how to work with them in Python, with clear examples youโ€ฆ
๐ŸŒ
LearnPython.com
learnpython.com โ€บ blog โ€บ how-to-download-file-in-python
How to Download a File in Python | LearnPython.com
December 23, 2021 - Our file has now been saved as fox.jpg. We just saw how to extract the URL in the API response by inspecting the json data. We have now learned how to download a file in Python over HTTP and from an API.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ python-read-json-file-how-to-load-json-from-a-file-and-parse-dumps
Python Read JSON File โ€“ How to Load JSON from a File and Parse Dumps
October 27, 2020 - Welcome! If you want to learn how to work with JSON files in Python, then this article is for you. You will learn: Why the JSON format is so important. Its basic structure and data types. How JSON and Python Dictionaries work together in Python. Ho...
๐ŸŒ
CodeRivers
coderivers.org โ€บ blog โ€บ loading-json-file-python
Loading JSON Files in Python: A Comprehensive Guide - CodeRivers
April 11, 2025 - It's part of the Python standard library, so you don't need to install any additional packages to use it. The json module contains functions for encoding Python objects to JSON strings (dumps and dump) and decoding JSON strings or files into Python objects (loads and load).