Downloader

class swpy.swds.request.Downloader

Bases: object

A class that handles functions related to data downloading, primarily dealing with JSON formatted 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

dict

url

URL from which JSON data is to be fetched.

Type

str

Methods Summary

print_data()

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_json attribute and prints its contents. Assuming that self.data_list_json is in dictionary format and contains the key data_list. The value of data_list is a list, and each item in the list is a dictionary with the keys time and name. If these assumptions are broken, the code may not function properly.

Parameters

None

Returns

None

download(self, file_path)

The download function downloads data from a specified URL, processes the JSON data, and saves the contents to a specified file path. Additionally, it includes functionality to validate the JSON data 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 Downloader can be read in the Examples page.