Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@MagiX13
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MagiX13/651e323c92ab86196a04 to your computer and use it in GitHub Desktop.
Save MagiX13/651e323c92ab86196a04 to your computer and use it in GitHub Desktop.
Python-LNP version checker and possible downloader
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