|
|

楼主 |
发表于 2015-5-30 22:52
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
自己结贴- Sub 抓取总数页()
- Dim StrJS As String, StrJun As String
- With CreateObject("msxml2.xmlhttp")
- '读取js文件,并替换document取值
- .Open "GET", "http://srh.bankofchina.com/search/js/wcm_page_2013.js", False
- .Send
- StrJS = Replace(.responsetext, "document.getElementById(PageContext.PageNav.NavId)", "'list_navigator'")
- '取网页中相关jscript代码
- .Open "POST", "http://srh.bankofchina.com/search/whpj/search.jsp", False
- .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- .Send "erectDate=2015-05-01¬hing=2015-05-30&pjname=0&page=2"
- StrJun = .responsetext
- StrJun = Mid(StrJun, InStr(StrJun, "function executeSearch()"))
- StrJun = Left(StrJun, InStr(StrJun, "function gotoPage(npage)") - 1)
- End With
- '将相关代码加入js中,运行相关function,取总页码
- MsgBox "共计" & JSEval(StrJS & ";" & StrJun & ";init_list();PageContext.params['PageCount']") & "页"
- End Sub
- Function JSEval(StrJS As String)
- Dim jss As Object
- Set jss = CreateObject("MSScriptControl.ScriptControl")
- With jss
- .Language = "javascript"
- JSEval = .Eval(StrJS)
- ' Stop
- End With
- End Function
- Sub CopyToClipbox(strText As String)
- With CreateObject("new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
- .SetText strText
- .PutInClipboard
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|