码迷,mamicode.com
首页 > 其他好文 > 详细

JNLP文件

时间:2018-06-28 16:02:57      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:exce   eve   offline   you   bin   attribute   codebase   nbsp   XA   

 

  • javaws -viewer可以查看已经下载的jar包
  • 用下面的python文件 下载jnlp文件中的jar包 (需要有访问权限)
#!/usr/bin/env python
#
# jnlp_crawler.py - Download all the jar files in a jnlp file for offline examination
# Sheran Gunasekera
#

from xml.dom.minidom import parse
from xml.parsers.expat import ExpatError
import urllib
import sys

to_download = []
try:
    dom = parse("yourpath")
except ExpatError as (strerror):
    print "!! JNLP File Parsing error -- "+str(strerror)
    sys.exit(1)
jnlp = dom.getElementsByTagName("jnlp")
codebase = jnlp[0].getAttribute("codebase")
resources = dom.getElementsByTagName("resources")
for resource in resources:
    jar = resource.getElementsByTagName("jar")
    for attributes in jar:
        to_download.append(attributes.getAttribute("href"))
for url in to_download:
    try:
        print "+ Attempt to fetch "+codebase+url
        urllib.urlretrieve(codebase+/+url,url.split(/)[-1])
        print "+ Done"
    except IOError as (errno, strerror):
        print "!! Failed -- "+strerror
    except KeyboardInterrupt:
        sys.exit(0)

 

JNLP文件

标签:exce   eve   offline   you   bin   attribute   codebase   nbsp   XA   

原文地址:https://www.cnblogs.com/darkcircle/p/9238892.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!