Testing installation of Package
Project description
Documentation for the Downloader
class
The Downloader
class provides functionality to download and unzip files from a specified URL using Selenium WebDriver.
Class Methods
__init__(self, download_directory="./", headless=True)
The constructor method initializes the Downloader
object. It takes two optional parameters:
download_directory
(default: "./"): Specifies the directory where the downloaded files will be saved.headless
(default: True): Determines whether the Chrome WebDriver runs in headless mode or not.
_wait_for_download(self, timeout=120)
This private method waits for the download to complete. It checks the Chrome Downloads page and returns the file paths of completed downloads. It takes an optional timeout
parameter (default: 120 seconds) to specify the maximum time to wait for the download to complete.
download_zip_files(self, url)
This method downloads zip files from a given URL. It performs the following steps:
- Navigates to the specified URL.
- Waits for the page to load.
- Locates and clicks the accept button.
- Finds the table element containing the files.
- Iterates through each row of the table and checks if the file has a ".svs" extension.
- If a ".svs" file is found, locates and clicks the download button.
- Waits for the download to complete.
- Logs the downloaded data.
- Closes the WebDriver.
download_specific_project_files(self, txt_file="./")
This method downloads zip files for specific projects listed in a text file. It takes an optional txt_file
parameter (default: "./") that specifies the path to the text file containing project names. The method reads the file and iterates through each project name, calling the download_zip_files
method for each project.
unzip_files(directory=None)
This static method extracts files from tar.gz archives in a specified directory. It takes a required directory
parameter that specifies the directory where the tar.gz files are located. The method loops through all files in the directory, identifies the ones with the ".tar.gz" extension, checks if the file size is greater than 0, and extracts the contents of the archive using the tarfile
module.
Example Usage
# Create an instance of the Downloader class
downloader = Downloader(download_directory="./downloads", headless=True)
# Download zip files for specific projects listed in a text file
downloader.download_specific_project_files(txt_file="./projects.txt")
# Unzip files in the specified directory
downloader.unzip_files(directory="./downloads")
Note: Before using this class, make sure you have the required dependencies installed (Selenium WebDriver, ChromeDriver, and tarfile module).
👥 Authors
👤 Manas
- Github: @manas1820
👤 Nishita
- Github: @NishitaPatnaik21
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file svs_dataset_downloader-0.0.3.tar.gz
.
File metadata
- Download URL: svs_dataset_downloader-0.0.3.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f60f4bed2dcdead1acb0f34adf9283cdeb190e46e597ef1160235162e3b3ab0 |
|
MD5 | c070cf346a3c44c295c110badb86b05d |
|
BLAKE2b-256 | 3fa092a3b5f7656b5fa5a23f422ca8d7a6f92a32c8d0515fb3e48fb3379f3be7 |