summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2019-06-09 12:20:13 +0200
committerneodarz <neodarz@neodarz.net>2019-06-09 12:20:13 +0200
commit623b71cb967ca1cb4c138967f957edd892ab7ab4 (patch)
tree108663f52c2044aedb0209f320928887c1dcabc5
downloadarchlinux_iso_checker-master.tar.xz
archlinux_iso_checker-master.zip
initial commitHEADmaster
-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("==================================")
+