【发布时间】:2018-05-09 18:12:51
【问题描述】:
我在 CURL 中有一个返回数据的命令。我尝试将其转换为 PowerShell 或 VBS,但我无法获取任何数据并且我的代码中没有错误消息。
以下是我的 CURL 命令:
$Data = curl "http://www.boursorama.com/ajax/ui/refresh.phtml/boursorama/block/bourse/derives/search/turbos?" -H "X-Requested-With: XMLHttpRequest" -H "X-Brs-Xhr-Request: true" --data "class=Boursorama_Block_Bourse_Derives_Search_Turbos" --compressed
以下是我的 Powershell 命令:
$hash =@{
"class" = "Boursorama_Block_Bourse_Derives_Search_Turbos"
}
$JSON = $hash | ConvertTo-Json
$R = Invoke-WebRequest -Method Post -URI "http://www.boursorama.com/ajax/ui/refresh.phtml/boursorama/block/bourse/derives/search/turbos?" -Headers @{"X-Brs-Xhr-Request"="true"} -Body $JSON -ContentType “application/json”
$R.Content
以下是我的 VBS 命令:
Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
strJSONToSend = "{""class"": ""Boursorama_Block_Bourse_Derives_Search_Turbos""}"
xmlhttp.open "POST","http://www.boursorama.com/ajax/ui/refresh.phtml/boursorama/block/bourse/derives/search/turbos?",False
xmlhttp.setRequestHeader "X-Brs-Xhr-Request", "true"
xmlhttp.send strJSONToSend
xmlhttp.responseText
我有最后一个问题,我正在尝试发送参数“page”,但结果相同,但页码不同。
以下是 PowerShell 命令:
$Data = Invoke-WebRequest -Method Post -URI "http://www.boursorama.com/ajax/ui/refresh.phtml/boursorama/block/bourse/derives/search/turbos?page=2" -Headers @{"X-Brs-Xhr-Request"="true";"X-Requested-With" = "XMLHttpRequest"} -body @{"class"="Boursorama_Block_Bourse_Derives_Search_Turbos";"parameters[page]"="2"}
我不知道参数必须在URL中还是在正文中发送。
【问题讨论】:
标签: json powershell curl