|
请帮忙看下这段代码,从《分享网页数据下载与控制》帖子中获取并修改,with一句出现编译错误,缺少参数,我不太懂请帮忙改改。只要取得文章名和日期就行。谢谢了。网站数据是分页的,第一页和最后一页的网址都是一样的。
Private Sub CommandButton1_Click()
weburl = "URL;http://www.linyi.gov.cn/all/all.htm1?colid=282"
Strpost = "year_start=%202011&month_start=%201&date_start=%201&" & _
"hour_start=%200" & _
"&year_end=%202011&month_end=%207&date_end=%2030&hour_end=%200" & _
"&substation%5B%5D=00&R1=sortall&order=1&desckey="
With Exsheet.QueryTables.Add(Connection:=weburl, & _
Destination:=Exsheet.Range("a1"))
.PostText = Strpost 'post字串
.BackgroundQuery = True
.WebSelectionType = xlSpecifiedTables
.WebTables = "1" '导入网页中的第一个表,也只有一个表格,网页上可能会包含很多个表格,表格让你组织网页内容。当在记事本里查看HTML源代码时,你会发现通过下述标签你很容易识别这些表格:<TABLE>(表格开始)和</TABLE>(表格结束)
.WebFormatting = xlWebFormattingAll
.RefreshStyle = xlOverwriteCells
.AdjustColumnWidth = True
On Error GoTo Wlcw
.Refresh BackgroundQuery:=False '发送命令?
On Error GoTo 0
.SaveData = True
End With
'数据已写入到EXCEL
……
Wlcw: '网络不通
If P_cxzlly = "sccx" Or P_cxzlly = "qmcx" Then
aa = MsgBox("网络不通,请手动打开网络试试!", vbOKOnly, "提示")
End If
Exit Sub
[ 本帖最后由 mantou008 于 2011-7-28 16:28 编辑 ] |
|