ScraperLib#
- class scraper_lib.ScraperLib.ScraperLib(base_url: str, file_patterns: List[str], download_dir: str = 'downloads', state_file: str = 'state/download_state.json', log_file: str = 'logs/scraper_log.log', output_dir: str = 'output', incremental: bool = True, max_files: int | None = None, max_concurrent: int | None = None, headers: Dict[str, str] | None = None, user_agents: List[str] | None = None, report_prefix: str = 'download_report', disable_logging: bool = False, disable_terminal_logging: bool = False, dataset_name: str | None = None, disable_progress_bar: bool = False, max_old_logs: int = 10, max_old_runs: int = 10, ray_instance: Any | None = None, chunk_size: str | int = '5MB', initial_delay: float = 1.0, max_delay: float = 60.0, max_retries: int = 5)[source]#
Bases:
objectLibrary for parallel file extraction and download, report generation, and log/result rotation.
- static build_arg_parser() ArgumentParser[source]#
Build the argument parser used by every entry point.
Exposed separately so that
docs/cli.rstcan render the flags with the.. argparse::directive straight from this definition. The page used to be maintained by hand and documented--output,--max-workersand--resume, none of which ever existed here.- Returns:
Parser with every documented flag.
- Return type:
argparse.ArgumentParser
The flag list is deliberately NOT repeated in prose here or in the parser epilog: add_argument below is the single source of truth and docs/cli.rst renders it directly.
- static cli(argv: List[str] | None = None) None[source]#
Command-line interface to run ScraperLib.
Parses arguments, instantiates ScraperLib and runs the process. Reached by
scraper,python -m scraper_libandpython -m scraper_lib.cli– seescraper_lib.cli.- Parameters:
argv (Optional[List[str]]) – Argument list; defaults to
sys.argv[1:].
- Usage example:
python -m scraper_lib –url <URL> –patterns .csv .zip –dir data –max-files 10