summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xarchlinux_checker.py44
1 files changed, 44 insertions, 0 deletions
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("==================================")
+