我正在试图抓住一个拥有用户身份验证的网站.我能够发一个POST来发送我的登录信息并存储一个cookie.但是,登录后,我在尝试访问受保护的页面时收到403错误.
$url = "https://some_url"
$CookieContainer = New-Object System.Net.CookieContainer
$postData = "User=UserName&Password=Pass"
$buffer = [text.encoding]::ascii.getbytes($postData)
[net.httpWebRequest] $req = [net.webRequest]::create($url)
$req.method = "POST"
$req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
$req.Headers.Add("Accept-Language: en-US")
$req.Headers.Add("Accept-Encoding: gzip,deflate")
$req.Headers.Add("Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7")
$req.AllowAutoRedirect = $false
$req.ContentType = "application/x-www-form-urlencoded"
$req.ContentLength = $buffer.length
$req.TimeOut = 50000
$req.KeepAlive = $true
$req.Headers.Add("Keep-Alive: 300");
$req.CookieContainer = $CookieContainer
$reqst = $req.getRequestStream()
$reqst.write($buffer, 0, $buffer.length)
$reqst.flush()
$reqst.close()
[net.httpWebResponse] $res = $req.getResponse()
$resst = $res.getResponseStream()
$sr = new-object IO.StreamReader($resst)
$result = $sr.ReadToEnd()
$res.close()
$url2 = "https://some_url/protected_page"
[net.httpWebRequest] $req2 = [net.webRequest]::create($url2) …Run Code Online (Sandbox Code Playgroud) 我必须将一个文件发布到服务器旁边,并附带几个post params.我从这个服务器管理员收到的文档显示了一个帖子请求应该是什么样子的例子(*注意POST的自定义内容类型"multipart/x-api-remote-integration"):
POST /gateway/remote_send HTTP/1.0
Content-Type: multipart/x-api-remote-integration; boundary=ABC1234
Content-Length: 323
--ABC1234
Content-Type: application/x-www-form-urlencoded
profile_name=username&profile_pw=password1234&attached_type=action_1
--ABC1234
Content-Type: text/csv
Content-Disposition: attachment; filename="attachment.csv"
row1
row2
row3
--ABC1234--
Run Code Online (Sandbox Code Playgroud)
下面是php代码:
<?php
function post(){
$base_api_url = "https://hostserver.com/gateway/remote_send";
$filename = realpath("/home/username/tests/test1234qwerty.csv");
$payload['profile_name'] = "username";
$payload['profile_pw'] = 'password1234';
$payload['attached_type'] = 'action_1';
$payload['filename'] = "@" . $filename . ";type=text/csv;";
$curl_options = array(
CURLOPT_URL => $base_api_url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query( $payload ),
CURLOPT_HTTP_VERSION => 1.0,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_VERBOSE => true,
CURLOPT_HEADER => false,
);
$curl …Run Code Online (Sandbox Code Playgroud) 我正在尝试在PowerShell 2.0中运行一个简单的作业流程,它似乎没有运行.
$job = Start-Job { Return "Some string." }
当我打电话给$ job时,状态显示它正在运行.但问题是它永远不会完成.
在我的Windows 7机器上尝试了同样的事情,它立即完成.
我正在windows xp上运行powershell 2.0.
有谁知道导致这个问题的原因是什么?我该如何解决这个问题?
这是我的 $PSVersionTable
Name Value
---- -----
PSVersion 2.0
PSCompatibleVersions {1.0, 2.0}
BuildVersion 6.0.6002.18111
PSRemotingProtocolVersion 2.1
WSManStackVersion 2.0
CLRVersion 4.0.30319.1
SerializationVersion 1.1.0.1
我正在尝试生成此doctype字符串:
<!DOCTYPE games SYSTEM "transform.dtd">
Run Code Online (Sandbox Code Playgroud)
这就是我一直在尝试的:
$writer.WriteDocType("games", $null , "transform.dtd", $null )
Run Code Online (Sandbox Code Playgroud)
我不完全确定如何获得那条确切的线.