- 注册时间
- 2011-3-21
- 最后登录
- 2022-3-22
- 在线时间
- 1191 小时
- 阅读权限
- 200
- 积分
- 9457
- 帖子
- 1256
- 精华
- 0
- UID
- 1
|
- Dim x, i, m, ms, cookies
- Set x = CreateObject("WinHTTP.WinHttpRequest.5.1")
- x.Option(6) = 0
- ' 先 POST 账户信息到登录验证页面
- x.Open "GET", "http://www.iscripts.org/forum.php", False
- x.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
- x.Send "username=%E6%B7%B7%E6%B7%B7@%E6%99%AE%E5%AE%81.%E4%B8%AD%E5%9B%BD&password=abcdefg"
- ' 保存 cookie
- With New RegExp
- .Pattern = "Set-Cookie:\s*([^;]+)"
- .Global = True
- .IgnoreCase = True
- Set ms = .Execute(x.GetAllResponseHeaders())
- ReDim cookies(ms.Count - 1)
- For i = 0 To UBound(cookies)
- cookies(i) = ms.Item(i).SubMatches(0)
- Next
- End With
- cookies = Join(cookies, "; ")
- ' 如果保存了 cookie, 那么在服务器 Session 记录未失效之前
- ' 把 cookie 提交,也能保持原来的会话
- Set x = CreateObject("WinHTTP.WinHttpRequest.5.1")
- x.Open "GET", "http://www.iscripts.org/main/", False
- x.SetRequestHeader "Cookie", cookies
- x.Send Null
- WScript.Echo x.ResponseText
复制代码 |
|