我将mywebsite替换为正确的网站,当我运行curl www.mywebsite.com时可以解析该网站。这些是我正在使用的选项:
curl -X 'GET https://www.mywebsite.com/Web2/PDF.aspx?page=1' \
-H 'Host: www.mywebsite.org' \
-H 'Connection: keep-alive' \
-H 'Upgrade-Insecure-Requests: 1' \
-A 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36 OPR/51.0.2830.26' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' \
-H 'DNT: 1' \
-e 'the-referer' \
-H 'Accept-Encoding: gzip, deflate, br' \
-H 'Accept-Language: en-US,en;q=0.9' \
-b '_the-cookies'
当我尝试在OSX终端中运行时,会发生以下情况:
$ curl -X 'GET https://www.mywebsite.com/Web2/PDF.aspx?page=1' \
-H 'Host: www.mywebsite.org' \
-H 'Connection: keep-alive' \
-H 'Upgrade-Insecure-Requests: 1' \
-A 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36 OPR/51.0.2830.26' \
curl: (6) Could not resolve host:
Mac-mini-3:~ myuser$
它说:
curl:(6)无法解析主持人:
为什么会这样?当我在终端中使用\ escape序列时,它为什么要尝试运行命令?在传递所有选项之前,它不应该运行任何命令。
答案 0 :(得分:1)
因为您尚未指定主机。主机被指定为请求命令(-X arg的一部分)。
您需要(注意单引号的位置)
卷曲-X GET' https://www.mywebsite.com/Web2/PDF.aspx?page=1' ...