Downloader¶
- class swpy.swds.request.Downloader¶
Bases:
objectA class that handles functions related to data downloading, primarily dealing with
JSONformatted data and including functionalities for downloading or printing it. To prevent security issues, you should only fetch data from trusted sources when downloading data from external URLs.- data_list_json¶
JSON data containing a list of data to download.
- Type
- url¶
URL from which JSON data is to be fetched.
- Type
Methods Summary
A function to print the list of data.
download(file_path)A function to download data.
Methods Documentation
- print_data(self)¶
The purpose is to create a function that reads the data stored in the
data_list_jsonattribute and prints its contents. Assuming that self.data_list_json is in dictionary format and contains the keydata_list. The value ofdata_listis a list, and each item in the list is a dictionary with the keystimeandname. If these assumptions are broken, the code may not function properly.- Parameters
None
- Returns
None
- download(self, file_path)¶
The
downloadfunction downloads data from a specified URL, processes theJSONdata, and saves the contents to a specified file path. Additionally, it includes functionality to validate theJSONdata and automatically set the file path. If you want to change the URL, you must verify its reliability. Security issues may arise if the URL contains malicious data.- Parameters
file_path (
str) – The path to save the downloaded file. It can have a special value 'skip', in which case the function automatically generates the file path.
- Returns
None
Usage of
Downloadercan be read in the Examples page.