Avoid the convenience of downloading jar files every time, through Python, request crawl target URL, mosaic download address. Implement a shortcut positioning operation.
Import requests Import json _dx_name = ' _download_top_url = ' http://nexus.td.internal/nexus/repository/' _download_gro up = ' maven-snapshots/' _suffix = '. jar ' _projectlist = [' Dx-web ', ' dx-aps ', ' dx-autotask ', ' dx-dm ', ' dx-mt ', ' dx-agent ' ] def requestnexus (): global R param1 = {"Action": "Coreui_search", "method": "read", "data": [{Page]: 1, "Start": 0, "limit": +, "sort": [{"Property": "Name", "direction": "ASC"}], "filter": [{' Property ': ' Format "," value ":" Maven2 "}, {" Property ":" Attributes.maven2.artifactId "," Value ": _dx_name}]}," type ":" RP C "," Tid ": 13} # company internal address URL = ' Http://192.168.15.188:28081/nexus/service/extdirect ' r = Requests.post (URL, jso
N=PARAM1) return R def Tranresult (r): print (r) result = Json.loads (r) data = result[' result ' [' data '] If Len (data) = = 0:print (' not match to content ... ') return rs_list = [] for d in data:path1 = d[' group '].replace ('. ', '/') + '/' path2 = _dx_name + '/' Path3 = (d[' version '].split ('-')) [0] + '-snapshot/' Path4 = _dx_name + '-' + d[' version '] global _download_group if d[' repositoryname '] = = ' Maven-snapshots ': _down Load_group = ' maven-snapshots/' elif d[' repositoryname '] = = ' maven-releases ': _download_group = ' maven -releases/' path3 = d[' version ' + '/' setsuffix () Download_url = _download_top_url + _downl
Oad_group + path1 + path2 + path3 + path4 + _suffix rs = d[' name '] + '-' + d[' version ' + ': ' + download_url # print (rs) map = {' name ': d[' name '] + '-' + d[' version ', ' Value ': Download_url} rs_list.append (ma P) return rs_list def setsuffix (): If _projectlist.__contains__ (_dx_name): Global _suffix _suff IX = '. War ' def GETURL (value): Global _dx_name _dx_name = value r = Requestnexus () rs = R.text retur N Tranresult (RS) if __name__ = = "__main__": _dx_name = input (' Please enter jar name: ') R = Requestnexus () rs = R.text _list = Tranresult (rs
For _map in _list:print (_map[' name '] + ': ' + _map[' value ')