From 623b71cb967ca1cb4c138967f957edd892ab7ab4 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sun, 9 Jun 2019 12:20:13 +0200 Subject: initial commit --- archlinux_checker.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 archlinux_checker.py diff --git a/archlinux_checker.py b/archlinux_checker.py new file mode 100755 index 0000000..cf1c511 --- /dev/null +++ b/archlinux_checker.py @@ -0,0 +1,44 @@ +#!/bin/python3 + +import requests, shutil, datetime +import os, re +from bs4 import BeautifulSoup + +base = "https://www.archlinux.org" +url = base+"/releng/releases/" + +# match yy.mm and yy.mm.dd archlinux version +regex = re.compile("[0-9]{4}\.[0-9]{2}.*") + +torrent_dir="./" + +def download_file(url): + filename = list(filter(regex.search, url.split('/'))) + if filename: + local_filename = torrent_dir+filename[0]+".torrent" + if not os.path.isfile(local_filename): + with requests.get(url, stream=True) as r: + with open(local_filename, 'wb') as f: + shutil.copyfileobj(r.raw, f) + return local_filename+" downloaded." + else: + return local_filename+" already exist." + else: + return "This is not a torrent..." + + +r = requests.get(url) + +soup= BeautifulSoup(r.text, 'lxml') + +tbody = soup.find('tbody') + +links = tbody.find_all('a', {'href': re.compile(r'torrent')}) + + +print("==========- {:%Y-%m-%d} -==========".format(datetime.datetime.now())) +print("==================================") +for link in links: + print(download_file(base+link['href'])) +print("==================================") + -- cgit v1.2.1