2014-09-21 46 views
0

我正在cmd中发送HTTP GET和POST请求cURL如何在cmd中工作时设置和获取变量

有很多次我发送请求到相同的页面,每次输入它们都是一个巨大的痛苦。

我想弄清楚如何使用set=,这样我可以保存这些URL每次我想要使用它们。

我已经试过

C:\>set page = "http://www.mywebpage.com/api/user/friends" 

C:\>page 
'page' is not recognized as an internal or external command, 
operable program or batch file. 

C:\>echo %page% 
%page% 

,但它不会返回页面名称。

我该如何完成我所需要的?

回答

1
C:\Windows\system32>set page="http://www.mywebpage.com/api/user/friends" 

C:\Windows\system32>echo %page% 
"http://www.mywebpage.com/api/user/friends" 

C:\Windows\system32>set page=http://www.mywebpage.com/api/user/friends 

C:\Windows\system32>echo %page% 
http://www.mywebpage.com/api/user/friends 

请勿在=附近使用空格。根据您的需要选择带或不带"的版本。变量值可以包含内部空间:

C:\Windows\system32>set page=http://www.mywebpage.com/api/user/my friends 

C:\Windows\system32>echo %page% 
http://www.mywebpage.com/api/user/my friends 
1

您正在设置值"http://www.mywebpage.com/api/user/friends"变量“页”内(注意空间),因为你有=之前的空间。

所以,你可以通过使用%page %或使用set page="http://..."没有页面和平等之间的空间检索值签订

+0

哇那是疯了!我没有意识到空间是重要的! – CodyBugstein 2014-09-21 12:41:26

相关问题