def fetch_and_parse_url(url): try: response = requests.get(url) response.raise_for_status() soup = BeautifulSoup(response.content, 'html.parser') return soup except requests.exceptions.RequestException as e: print(f"Error fetching the URL: {e}") return None def get_tar_gz_links(soup): links = soup.find_all('a', href=True) tar_gz_links = [link['href'] for link in links if link['href'].endswith('.tar.gz')] return tar_gz_links def join_urls(base_url, relative_urls): return [urljoin(base_url, rel_url) for rel_url in relative_urls] def download_file(basePath, url): local_filename = url.split('/')[-1] local_filename = os.path.join(basePath, local_filename) with requests.get(url, stream=True) as r: r.raise_for_status() with open(local_filename, 'wb') as f: for chunk in r.iter_content(chunk_size=8192): f.write(chunk) return local_filename