首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用Python下载归档文件

使用Python下载归档文件
EN

Stack Overflow用户
提问于 2020-07-17 01:07:06
回答 1查看 26关注 0票数 0

我需要从这个链接下载归档文件:

http://ftp.itrc.hp.com/wpsl/bin/getFile.pl?Path=/export/patches/swa_catalog.xml.gz&Auth=05010610777284199948925117

然后我需要保存它并解压缩它。我该怎么做呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-17 23:43:32

代码语言:javascript
运行
复制
import gzip
import requests

url = 'http://ftp.itrc.hp.com/wpsl/bin/getFile.pl?Path=/export/patches/swa_catalog.xml.gz&Auth=05010610777284199948925117'
xml_file = gzip.decompress(requests.get(url).content).decode('utf-8')

print(xml_file)

打印:

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8" ?>
<!--                                                                       -->
<!-- (c)Copyright 2000-2008 Hewlett-Packard Co.,  All Rights Reserved.      -->
<!--               RESTRICTED RIGHTS LEGEND                        -->
<!-- Use, duplication, or disclosure by the U.S. Government is subject to   -->
<!-- restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in -->
<!-- Technical Data and Computer Software clause in DFARS 252.227-7013.     -->
<!--                                                                       -->
<!--                                                                       -->
<!--               Hewlett-Packard Company                         -->
<!--               3000 Hanover Street                             -->
<!--               Palo Alto, CA 94304 U.S.A.                      -->
<!--                                                                       -->
<!-- Rights for non-DOD U.S. Government Departments and Agencies are as set -->
<!-- forth in FAR 52.227-19(c)(1,2).                                        -->
<!--                                                                       -->
<!--created on 2020-07-17T14:02:31+0000 by NDist 6.2.0 (PC SIMP 2)-->
<items>
  <catalogDate value="2020-07-17T14:02:31+0000"/>
<!--from /var/opt/support/ndist/dta/current/hp-ux_patches.xml.swa.filt-->
<patch id="PHKL_21752" flags="S" cdate="2000-05-26" pdate="2000-07-28" status="GS" reboot="A" crit="N" sec="N">
<desc text="s700_800 11.04 (VVOS) Cumulative pstat fix and optimization"/>

... and so on.
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62939938

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档