|
获取网页数据,录了一个宏,但是登录的部分录制不了,代码如下:
Sub Macro1()
'
' Macro1 Macro
' 宏由 ???? 录制,时间: 2015-10-24
'
' 快捷键: Ctrl+e
'
With Selection.QueryTable
.Connection = _
"URL;file:///http://www.haomaohm.com/wbjhoutai.php?moduleid=21&action=&fields=0&kw=&level=0&order=0&psize=10000&datetype=addtime&fromdate=20151023&todate=&catid=0&areaid=0&itemid="
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "4"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Selection.QueryTable.Refresh BackgroundQuery:=False
End Sub
模块2是登录的代码:
Sub 登录()
On Error Resume Next
Set IE = CreateObject("InternetExplorer.application")
IE.navigate "file:///http://www.haomaohm.com/wbjhoutai.php?moduleid=21&action=&fields=0&kw=&level=0&order=0&psize=10000&datetype=addtime&fromdate=20151023&todate=&catid=0&areaid=0&itemid="
IE.Visible = True
Do Until IE.readystate = 4
DoEvents
Loop
With IE.document
.getelementbyid("username").Value = "XXX" 'ÓÑô?¤Ì–
.getelementbyid("password").Value = "******" 'ÓÑôÃÜ´a
End With
Do Until IE.readystate = 4
DoEvents
Loop
'ie.Quit
'Set ie = Nothing
SendKeys "{ENTER}", True
End Sub
两段代码都测试正常,但是怎么把这2段代码整合到一起啊。求大神帮忙看看,求教了。
|
|