GCGM Asked: 2019-08-30 02:33:44 +0800 CST2019-08-30 02:33:44 +0800 CST 2019-08-30 02:33:44 +0800 CST 来自终端的 HTTP 请求的 XML 输出 772 我正在HTTP使用从终端发送请求curl,并希望查看或保存输出(默认情况下输入xml)。 这是我正在使用的代码: curl https://catalogue.onda-dias.eu/dias-catalogue/Products?$search="name:S1A_IW_OCN__2SDV_20170904T063918_20170904T063943_018222_01EA1A_8E10.zip" 输出包含很多(在我看来)随机文本(见图 1) 如果我http在浏览器上运行相同的请求(参见图 2),我会在 xml 中获得输出(我需要 xml 来提取一次包含的参数) command-line https xml curl 1 个回答 Voted Best Answer aropan 2019-08-30T03:08:33+08:002019-08-30T03:08:33+08:00 您可以从开发人员工具中复制 curl 命令: 核实: curl 'https://catalogue.onda-dias.eu/dias-catalogue/Products?$search=%22name:S1A_IW_OCN__2SDV_20170904T063918_20170904T063943_018222_01EA1A_8E10.zip%22' -H 'Connection: keep-alive' -H 'Cache-Control: max-age=0' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-User: ?1' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'Sec-Fetch-Site: none' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: ru-RU,ru;q=0.9' -H 'Cookie: SRVNAME=N02' --compressed 只要有效,您就可以删除不必要的标题: curl 'https://catalogue.onda-dias.eu/dias-catalogue/Products?$search=%22name:S1A_IW_OCN__2SDV_20170904T063918_20170904T063943_018222_01EA1A_8E10.zip%22' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' 或短版(-H 'Accept: application/xml仅添加): curl 'https://catalogue.onda-dias.eu/dias-catalogue/Products?$search=%22name:S1A_IW_OCN__2SDV_20170904T063918_20170904T063943_018222_01EA1A_8E10.zip%22' -H 'Accept: application/xml'
您可以从开发人员工具中复制 curl 命令:
核实:
只要有效,您就可以删除不必要的标题:
或短版(
-H 'Accept: application/xml
仅添加):