-
-
Save MagiX13/651e323c92ab86196a04 to your computer and use it in GitHub Desktop.
Python-LNP version checker and possible downloader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
import re | |
import shutil | |
packagenr=9195 | |
requ=urllib.request | |
req=requ.Request(''.join(["http://dffd.wimbli.com/file_version.php?id=", str(packagenr)]),headers={'User-Agent':'python-LPN-project'}) | |
resp=requ.urlopen(req) | |
version=0 | |
for line in resp: | |
tmp=line.decode('utf-8') | |
if (tmp.find('dated')>0): | |
version=tmp[9:19] | |
print(version) | |
# do some version check here | |
req2=requ.Request(''.join(["http://dffd.wimbli.com/file.php?id=",str(packagenr)]),headers={"User-Agent":"python-LNP-project"}) | |
resp2=requ.urlopen(req2) | |
for line in resp2: | |
tmp=line.decode("utf-8") | |
if (tmp.find('download.php')>0): | |
fileurl = ''.join(['http://dffd.wimbli.com/',re.sub(r'amp;','',tmp[tmp.find('download.php'):tmp.find('\">')])]) | |
print(fileurl) | |
filename=fileurl[(fileurl.find('f=')+2):] | |
tmp=requ.Request(fileurl,headers={"User-Agent":"python-LNP-project"}) | |
with requ.urlopen(tmp) as response, open(filename,'wb') as out_file: | |
shutil.copyfileobj(response, out_file) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment