|
楼主 |
发表于 2014-11-21 17:55
|
显示全部楼层
kangatang 发表于 2014-11-21 10:09
很多时候跟缓存无关。楼主别再纠结缓存问题。
为了楼主少走冤枉路,提醒一下: :
1) 关Excel,就是关闭xml ... - Sub loginstatus() '查登陆状态
- On Error GoTo msg
- Dim ul$, strText$, http
- ul = "http://www.apabi.com/cdyxy/?pid=usp.catsearch"
- ul = ul & "&db=dlib"
- ul = ul & "&dt=EBook"
- ul = ul & "&cult=CN"
- ul = ul & "&of=PublishDate"
- ul = ul & "&om=desc"
- ul = ul & "&ct=CYFL2011%24%24"
- ul = ul & "&cl=0" '类别级次,0~2
- ul = ul & "&il=0" '是否有下级,0有,1无
- ul = ul & "&sct=1" '是否只显示可整本阅读的书,4是全部
- ul = ul & "&pg=1" '页数
- ' ul = ul & "&t=" & Int(Rnd() * 10 ^ 8) '缓存中不保留
- Set http = CreateObject("MSXML2.XMLHTTP")
- With http
- .Open "GET", ul, False
- ' .setRequestHeader "Cache-Control", "no-cache"
- .setRequestHeader "If-Modified-Since", "0"
- .send
- strText = .responsetext
- If Split(Split(strText, "<title>")(1), "<")(0) = "中华数字书苑-用户登录" Then
- instatus = False
- ElseIf Split(Split(strText, "<title>")(1), "<")(0) = "中华数字书苑-中华数字文明精粹" Then
- instatus = True
- End If
- ExitAll = False
- End With
- Exit Sub
- msg:
- If Err.Number = -2146697211 Then
- MsgBox "请检查网络状况!", 0 + 64, "网络故障!"
- ExitAll = True
- Exit Sub
- End If
- End Sub
复制代码 我是在网抓的过程中间故意断网,然后执行这段代码查看登陆状态,执行到send就近十分钟不响应。如果打开文件直接执行这段代码就能很快判断网络状况。
老师我看到网上您提到的两句代码:
.setRequestHeader "Cache-Control", "no-cache"
.setRequestHeader "If-Modified-Since", "0"
但都send后的不响应都不起作用。而status和readystate似乎只有在send相应完后才能看到,不知道还有什么方法 |
|