小编nik*_*nik的帖子

Powershell - Invoke-WebRequest到一个带有文字'/'(%2F)的URL

我一直在尝试/使用以下命令从powershell 访问带有字符的URL (它是对gitlab服务器的查询以检索调用的项目"foo/bar"):

Invoke-WebRequest https://server.com/api/v3/projects/foo%2Fbar -Verbose
Run Code Online (Sandbox Code Playgroud)

现在,奇怪的是使用PowerShell ISE或Visual Studio,请求是正常的.使用PowerShell本身时,URL会自动取消转义,并且请求失败.例如

在ISE/VS中:

$> Invoke-WebRequest https://server.com/api/v3/projects/foo%2Fbar -Verbose
VERBOSE: GET https://server.com/api/v3/projects/foo%2Fbar with 0-byte payload
VERBOSE: received 19903-byte response of content type application/json

StatusCode        : 200
StatusDescription : OK
Content           : .... data ....
Run Code Online (Sandbox Code Playgroud)

在Powershell中:

$> Invoke-WebRequest https://server.com/api/v3/projects/foo%2Fbar -Verbose
VERBOSE: GET https://server.com/api/v3/projects/foo/bar with 0-byte payload
Invoke-WebRequest : {"error":"404 Not Found"}
At line:1 char:1
+ Invoke-WebRequest 'https://server.com/api/v3/projects/foo%2Fbar ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Run Code Online (Sandbox Code Playgroud)

我尝试在URL周围添加单引号和双引号,但没有任何帮助. …

url powershell webrequest urlencode

7
推荐指数
1
解决办法
4000
查看次数

从scapy数据包中获取信息字符串

我在我正在构建的工具中非交互式地使用scapy 2.3.1-dev(即作为库).我想获得一些关于数据包的人类可读信息,例如你从中得到的信息scapy.all.Packet.show().我已经尝试使用提供信息的所有三种方法(packet.show(),packet.show2()packet.display()),但这些方法都没有返回任何内容,而是打印出我想要的信息.

此外,返回的信息还packet.__repr__()不够.

是否有任何函数/方法可以像packet.show()打印它们一样返回格式良好的文本?如果没有,有什么方法show()可以在打印到控制台之前捕获/拦截输出?

我知道我可以使用来自的信息进行自己的字符串格式化packet.fields,但我试图避免必须这样做.

python scapy python-2.7

4
推荐指数
2
解决办法
7867
查看次数

标签 统计

powershell ×1

python ×1

python-2.7 ×1

scapy ×1

url ×1

urlencode ×1

webrequest ×1